Self-hosted dashboard and admin auth (#4837)
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
This commit is contained in:
co-authored by
kartik-mem0
parent
15feaa8ac4
commit
db8ac61713
@@ -0,0 +1,20 @@
|
||||
import axios from "axios";
|
||||
|
||||
export function getErrorMessage(
|
||||
err: unknown,
|
||||
fallback = "Something went wrong",
|
||||
): string {
|
||||
if (axios.isAxiosError(err)) {
|
||||
const detail = err.response?.data?.detail;
|
||||
if (typeof detail === "string") return detail;
|
||||
if (Array.isArray(detail) && detail.length > 0) {
|
||||
const first = detail[0];
|
||||
if (typeof first === "string") return first;
|
||||
if (first?.msg) return String(first.msg);
|
||||
}
|
||||
if (err.message) return err.message;
|
||||
}
|
||||
if (err instanceof Error && err.message) return err.message;
|
||||
if (typeof err === "string") return err;
|
||||
return fallback;
|
||||
}
|
||||
Reference in New Issue
Block a user