/** * Pure helpers for unwrapping route loader errors into a human-readable * description. Kept separate from the React component so the branching logic * (axios with/without response, Apollo network vs GraphQL errors, HTTP status * mapping) can be unit-tested without rendering. * * No new dependencies: axios and Apollo error shapes are duck-typed so the * helpers do not force consumers to install either package. */ export type RouteErrorDescription = { status: 'error' | 'warning' | 'info'; title: string; subTitle: string; details: string | null; }; type AxiosErrorLike = Error & { isAxiosError: true; response?: { status: number; statusText?: string; data?: unknown; }; config?: { url?: string; method?: string; }; code?: string; }; type ApolloErrorLike = Error & { graphQLErrors?: ReadonlyArray<{ message?: string; }>; networkError?: unknown; }; export declare function isAxiosError(error: unknown): error is AxiosErrorLike; export declare function isApolloError(error: unknown): error is ApolloErrorLike; /** * Maps an HTTP status code to the antd `Result` status type used to colour the * icon. 4xx is treated as a warning (the user can usually act on it); 5xx and * anything else is an error. */ export declare function statusToType(status: number): 'error' | 'warning'; /** * Pulls a user-facing message out of a JSON response body. Tries `message`, * `error`, then `detail` — the keys most APIs we talk to actually use. */ export declare function extractResponseMessage(data: unknown): string | null; export declare function formatDetails(input: Record): string | null; export declare function safeStringify(value: unknown): string; export declare function describeHttp(status: number, statusText: string | undefined, data: unknown, detailsExtras?: Record): RouteErrorDescription; export declare function unwrapAxios(error: unknown): RouteErrorDescription | null; export declare function unwrapApollo(error: unknown): RouteErrorDescription | null; /** * Top-level dispatch. Tries each known error shape in turn; falls back to a * generic description for unknown values so the UI never blanks out. * * Order matters: * - Apollo before Axios: an ApolloError's `networkError` is often an * AxiosError, and the Apollo branch recursively delegates so that path * still produces the axios description. * - Apollo and Axios before the Response-like check: axios v1 exposes * `error.status` as a getter, which would otherwise be misclassified as a * thrown Response. */ export declare function describeRouteError(error: unknown): RouteErrorDescription; export {}; //# sourceMappingURL=Error.utils.d.ts.map