import type { ErrorDetail } from "./error-message.js"; export interface ApiErrorFacts { /** HTTP status, when the error came from an API response. */ status: number | undefined; /** Stable machine code from the response body, if any. */ code: string | undefined; /** The request reference for support. */ reference: string | undefined; /** The server's own sentence, without the status prefix or the reference. */ serverMessage: string | undefined; } /** Splits an error into the facts it carries. Never throws. */ export declare function apiErrorFacts(error: unknown): ApiErrorFacts; /** True for an error that came from an API response (or reads like one). */ export declare function isApiError(error: unknown): boolean; /** * The viewer lacks a permission. Retrying can't help: say who can grant it * instead of showing an error. */ export declare function isPermissionDenied(error: unknown): boolean; /** * What to do next, in one sentence. Pair it with a title that says what * happened ("Couldn't add the webhook"). */ export declare function apiErrorAdvice(error: unknown): string; /** * The text to show for a failed action where only one line fits (a toast * description, a form error). API errors become advice, followed by the * request reference for support; an error the app wrote itself keeps its own * message. Next to Technical details (which already show the reference), use * `userErrorTextWithoutReference`. */ export declare function userErrorText(error: unknown, fallback?: string): string; /** * A user-facing error for a form or dialog, keeping the original as its cause. * An API error becomes what to do next, never its raw "Opengeni API ..." text. */ export declare function userFacingError(error: unknown, message?: string): Error; /** * `userErrorText` without the request reference, for places that show the * reference behind Technical details already (`apiErrorDetails`, * `apiErrorTechnicalFacts`). */ export declare function userErrorTextWithoutReference(error: unknown, fallback?: string): string; /** * Props for `ErrorMessage`'s Technical details: the reference (with Copy), * then the status, code and the server's own message. */ export declare function apiErrorDetails(error: unknown): { reference?: string; details: ErrorDetail[]; }; /** Every Technical details fact of an error, the reference last with Copy. Empty for app errors. */ export declare function apiErrorTechnicalFacts(error: unknown): ErrorDetail[];