mirror of
https://github.com/docmost/docmost.git
synced 2026-07-22 17:44:18 +10:00
- default status
- type fix - error helper
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { isAxiosError } from "axios";
|
||||
|
||||
export function getApiErrorMessage(
|
||||
error: unknown,
|
||||
fallback = "An error occurred",
|
||||
): string {
|
||||
if (isAxiosError(error)) {
|
||||
const message = error.response?.data?.message;
|
||||
if (Array.isArray(message)) {
|
||||
const joined = message.filter(Boolean).join(", ");
|
||||
if (joined) return joined;
|
||||
} else if (typeof message === "string" && message.trim()) {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./utils";
|
||||
export * from "./api-error";
|
||||
|
||||
Reference in New Issue
Block a user