Download frontend/src/utils/apiError.js from yahyoha/omnidiag: direct link, hf CLI and curl.
- Browser
- Download file 698 Bytes
-
https://huggingface.co/spaces/yahyoha/omnidiag/resolve/main/frontend/src/utils/apiError.js
- Command line
-
hf download hf://spaces/yahyoha/omnidiag/frontend/src/utils/apiError.js
-
curl -L -o apiError.js https://huggingface.co/spaces/yahyoha/omnidiag/resolve/main/frontend/src/utils/apiError.js
698 Bytes
| /** | |
| * The reason a non-OK response gives, as one line for the screen. | |
| * | |
| * Every backend error body carries `error` (backend/main.py wraps each | |
| * HTTPException in the same envelope); a refusal for a retired module also | |
| * carries `reason` (410 DISEASE_RETIRED). Anything else falls back to the | |
| * HTTP status text, so a failure is never shown as nothing at all. | |
| */ | |
| export async function responseError(res) { | |
| let body = {}; | |
| try { | |
| body = await res.json(); | |
| } catch { | |
| // not JSON | |
| } | |
| const main = body?.error | |
| || (typeof body?.detail === 'string' ? body.detail : null) | |
| || res.statusText | |
| || `HTTP ${res.status}`; | |
| return body?.reason ? `${main} ${body.reason}` : main; | |
| } | |