Spaces:
Running
Running
Download bioai-platform/frontend/src/lib/errors.ts from Samad14/bio-nexus-api: direct link, hf CLI and curl.
- Browser
- Download file 638 Bytes
-
https://huggingface.co/spaces/Samad14/bio-nexus-api/resolve/main/bioai-platform/frontend/src/lib/errors.ts
- Command line
-
hf download hf://spaces/Samad14/bio-nexus-api/bioai-platform/frontend/src/lib/errors.ts
-
curl -L -o errors.ts https://huggingface.co/spaces/Samad14/bio-nexus-api/resolve/main/bioai-platform/frontend/src/lib/errors.ts
638 Bytes
| import { AxiosError } from 'axios'; | |
| export function extractErrorMessage(err: unknown, fallback = 'Request failed'): string { | |
| if (err instanceof AxiosError) { | |
| const detail = err.response?.data; | |
| if (detail && typeof detail === 'object' && 'detail' in detail && typeof detail.detail === 'string') { | |
| return detail.detail; | |
| } | |
| return err.message || fallback; | |
| } | |
| if (err instanceof Error) { | |
| return err.message || fallback; | |
| } | |
| return fallback; | |
| } | |
| export function extractErrorStatus(err: unknown): number | undefined { | |
| if (err instanceof AxiosError) { | |
| return err.response?.status; | |
| } | |
| return undefined; | |
| } | |