Spaces:
Runtime error
Runtime error
Download src/lib/utils/stringifyError.ts from evijit/pluralchat: direct link, hf CLI and curl.
- Browser
- Download file 575 Bytes
-
https://huggingface.co/spaces/evijit/pluralchat/resolve/refs%2Fpr%2F1/src/lib/utils/stringifyError.ts
- Command line
-
hf download hf://spaces/evijit/pluralchat@refs/pr/1/src/lib/utils/stringifyError.ts
-
curl -L -o stringifyError.ts https://huggingface.co/spaces/evijit/pluralchat/resolve/refs%2Fpr%2F1/src/lib/utils/stringifyError.ts
575 Bytes
| /** Takes an unknown error and attempts to convert it to a string */ | |
| export function stringifyError(error: unknown): string { | |
| if (error instanceof Error) return error.message; | |
| if (typeof error === "string") return error; | |
| if (typeof error === "object" && error !== null) { | |
| // try a few common properties | |
| if ("message" in error && typeof error.message === "string") return error.message; | |
| if ("body" in error && typeof error.body === "string") return error.body; | |
| if ("name" in error && typeof error.name === "string") return error.name; | |
| } | |
| return "Unknown error"; | |
| } | |