import { MisinaError } from "./base.mjs"; /** * RFC 9457 problem details (formerly RFC 7807). Servers signal application * errors with `Content-Type: application/problem+json` and this shape. */ export interface ProblemDetails { /** URI reference identifying the problem type. Default `"about:blank"`. */ type?: string; /** Short, human-readable summary. */ title?: string; /** HTTP status code (echoed). */ status?: number; /** Specific occurrence detail. */ detail?: string; /** URI reference identifying the specific occurrence. */ instance?: string; /** Custom extension fields are allowed by the spec. */ [key: string]: unknown; } /** * Thrown when the server responds with a non-2xx status and `throwHttpErrors` * is true (the default). Carries the parsed body as `data`, the original * `Request` and `Response`, and surfaces RFC 9457 `problem+json` details on * `.problem` when applicable. * * @example * ```ts * import { HTTPError, isHTTPError } from "misina" * * try { * const { data } = await api.post("/users", { name: "Alice" }) * } catch (err) { * if (isHTTPError<{ message: string }>(err)) { * // err.status, err.data.message, err.response.headers all typed * showToast(err.problem?.title ?? err.data.message) * } else throw err * } * ``` */ export declare class HTTPError extends MisinaError { override readonly name = "HTTPError"; readonly status: number; readonly statusText: string; readonly response: Response; readonly request: Request; readonly data: T; /** * Parsed RFC 9457 problem details — present when the response had * `Content-Type: application/problem+json` and a JSON body. `undefined` * otherwise. */ readonly problem: ProblemDetails | undefined; /** * Server-issued request id, read from response headers. Surfaced in the * error message as `[req: ]` and included in toJSON. Default scan * order: `x-request-id`, `request-id`, `x-correlation-id`. Override via * `requestIdHeaders` on `createMisina`. */ readonly requestId: string | undefined; constructor(response: Response, request: Request, data: T, requestIdHeaders?: readonly string[]); override toJSON(): Record; }