import { OutgoingRequest } from "./Http.types.mjs"; //#region ../http/src/HttpError.d.ts /** * Structured error thrown (or returned) by every Http method. * * All properties and predicates are accessible without calling a function: * if (error.isAborted) { return; } * if (error.isNotFound) { return null; } * if (error.isValidationError) { return showErrors(error.body); } * console.log(error.headers?.['x-request-id']); */ declare class HttpError extends Error { /** HTTP status code, or null for network/abort/timeout errors. */ readonly status: number | null; /** Parsed response body (JSON if Content-Type is application/json, else raw text). */ readonly body: unknown; /** The raw Response object, if a response was received. */ readonly response: Response | null; /** True when the request was cancelled via AbortController. */ readonly isAborted: boolean; /** True when the request hit the timeout limit. */ readonly isTimeout: boolean; /** True for network-level failures (DNS, CORS, no connection). */ readonly isNetwork: boolean; /** * Response headers as a plain object. null when no response was received * (network error, timeout, or abort). * * Shortcut so you don't have to reach into `error.response?.headers.get(...)`: * const remaining = error.headers?.['x-rate-limit-remaining']; */ readonly headers: Record | null; /** * The outgoing request that triggered this error, with sensitive headers * (Authorization, Cookie, …) redacted — safe to log directly. * Useful in `throw: true` mode where you only have the HttpError (no HttpResult). * * Use `rawRequest` if you need the live, unredacted headers. */ readonly request: OutgoingRequest | null; /** * The outgoing request with its original, unredacted headers. * May contain live `Authorization`/`Cookie` values — do not log this without * redacting first. */ readonly rawRequest: OutgoingRequest | null; constructor(opts: { message: string; status?: number | null; body?: unknown; response?: Response | null; isAborted?: boolean; isTimeout?: boolean; isNetwork?: boolean; headers?: Record | null; request?: OutgoingRequest | null; }); /** 4xx status code. */ get isClientError(): boolean; /** 5xx status code. */ get isServerError(): boolean; /** 401 Unauthorized. */ get isUnauthorized(): boolean; /** 403 Forbidden. */ get isForbidden(): boolean; /** 404 Not Found. */ get isNotFound(): boolean; /** 422 Unprocessable Entity — typical validation error. */ get isValidationError(): boolean; /** 429 Too Many Requests. */ get isRateLimited(): boolean; toJSON(): Record; } //#endregion export { HttpError }; //# sourceMappingURL=HttpError.d.mts.map