21 lines
454 B
TypeScript
21 lines
454 B
TypeScript
export function isErrorStatus(status: string): boolean {
|
|
return status.startsWith("error") || status.startsWith("failed");
|
|
}
|
|
|
|
export function formatError(e: unknown): string {
|
|
if (e instanceof Error) {
|
|
return e.message || e.toString();
|
|
}
|
|
if (typeof e === "string") {
|
|
return e;
|
|
}
|
|
if (e && typeof e === "object") {
|
|
try {
|
|
return JSON.stringify(e, null, 2);
|
|
} catch {
|
|
return String(e);
|
|
}
|
|
}
|
|
return String(e);
|
|
}
|