Download webui/src/lib/error-message.ts from xjackkx/rg: direct link, hf CLI and curl.
- Browser
- Download file 510 Bytes
-
https://huggingface.co/spaces/xjackkx/rg/resolve/main/webui/src/lib/error-message.ts
- Command line
-
hf download hf://spaces/xjackkx/rg/webui/src/lib/error-message.ts
-
curl -L -o error-message.ts https://huggingface.co/spaces/xjackkx/rg/resolve/main/webui/src/lib/error-message.ts
510 Bytes
| import { ApiError } from "./api-client"; | |
| type TranslateFn = (text: string, options?: Record<string, unknown>) => string; | |
| export function formatApiErrorMessage(error: unknown, t: TranslateFn): string { | |
| if (error instanceof ApiError) { | |
| const message = error.message ? t(error.message) : t("未知错误"); | |
| return error.code ? `${error.code}: ${message}` : message; | |
| } | |
| if (error instanceof Error) { | |
| return error.message ? t(error.message) : t("未知错误"); | |
| } | |
| return t("未知错误"); | |
| } | |