@arizeai/phoenix-client
Version:
A client for the Phoenix API
18 lines (17 loc) • 438 B
text/typescript
export function formatApiError(error: unknown): string {
if (typeof error === "string") {
return error;
}
if (error && typeof error === "object") {
const errorWithDetail = error as { detail?: unknown };
if (typeof errorWithDetail.detail === "string") {
return errorWithDetail.detail;
}
try {
return JSON.stringify(error);
} catch {
return String(error);
}
}
return String(error);
}