Spaces:
Running
Running
deploy(hf): sync szl-holdings/nexus@00edebc993282efd5b43b0144b3d3d27ab43e264 derived COPY set
31b3c47 verified Download src/lib/app-data/errors.ts from SZLHOLDINGS/nexus: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/SZLHOLDINGS/nexus/resolve/main/src/lib/app-data/errors.ts
- Command line
-
hf download hf://spaces/SZLHOLDINGS/nexus/src/lib/app-data/errors.ts
-
curl -L -o errors.ts https://huggingface.co/spaces/SZLHOLDINGS/nexus/resolve/main/src/lib/app-data/errors.ts
1.38 kB
| import type { CallToolResult } from "./types.ts"; | |
| import { isLoginRequired } from "./login.ts"; | |
| export type CallToolErrorKind = | |
| | "login" | |
| | "not_connected" | |
| | "scope_denied" | |
| | "access_denied" | |
| | "error"; | |
| export type CallToolErrorState = { | |
| kind: CallToolErrorKind; | |
| message: string; | |
| detail?: string; | |
| }; | |
| export function classifyCallToolError( | |
| result: CallToolResult, | |
| ): CallToolErrorState | null { | |
| if (result.ok) return null; | |
| const detail = result.errorMessage || undefined; | |
| const raw = (result.errorMessage ?? "").toLowerCase(); | |
| if (isLoginRequired(result)) { | |
| return { | |
| kind: "login", | |
| message: "Continue with Grok to load your data.", | |
| detail, | |
| }; | |
| } | |
| if (raw.includes("not_connected") || raw.includes("failed_precondition")) { | |
| return { | |
| kind: "not_connected", | |
| message: "Connect this connector in Grok to load your data.", | |
| detail, | |
| }; | |
| } | |
| if (raw.includes("scope_denied")) { | |
| return { | |
| kind: "scope_denied", | |
| message: "This view isn't available — the app requested a tool outside its grant.", | |
| detail, | |
| }; | |
| } | |
| if (raw.includes("access_denied")) { | |
| return { | |
| kind: "access_denied", | |
| message: "You don't have access to this data.", | |
| detail, | |
| }; | |
| } | |
| return { | |
| kind: "error", | |
| message: detail ?? "Something went wrong. Try again.", | |
| detail, | |
| }; | |
| } | |