/** * SDK error model. Two distinct failure modes: * - GoableApiError : the API returned a non-2xx response. Maps the * canonical flat error envelope * ({ error, message?, issues?, detail? }). * - GoableNetworkError: the request never produced an HTTP response * (DNS, connection, abort/timeout, JSON parse). */ export interface ZodIssueLike { code?: string; path?: Array; message?: string; [k: string]: unknown; } /** Rate-limit snapshot parsed from `X-RateLimit-*` response headers. Present * when the server sent them (currently the `score` + `recommend-spot` * endpoints; omitted on unlimited Scale plans). */ export interface RateLimit { /** `X-RateLimit-Limit` — daily safety cap for this endpoint + plan. */ limit: number; /** `X-RateLimit-Remaining` — requests left in the current window. */ remaining: number; /** `X-RateLimit-Reset` — Unix timestamp (seconds) when the window resets. */ reset: number; } /** Structured extras attached to a {@link GoableApiError}. */ export interface ApiErrorExtra { issues?: ZodIssueLike[]; detail?: Record; retryAfterSeconds?: number | null; rateLimit?: RateLimit; } export declare class GoableApiError extends Error { readonly name: string; /** HTTP status code. */ readonly status: number; /** Machine-readable code from the `error` field (e.g. "PAYMENT_REQUIRED"). */ readonly code: string; /** Zod validation issues, present on 422 VALIDATION_ERROR responses. */ readonly issues?: ZodIssueLike[]; /** Free-form extra context (e.g. plan info, quote id). */ readonly detail?: Record; /** Seconds to wait before retrying, from the `Retry-After` header. Set on a * `429`; `null` when the header is absent or unparseable. Lets a caller * implement a compliant back-off (`if (err.status === 429) sleep(err.retryAfterSeconds)`). */ readonly retryAfterSeconds: number | null; /** Rate-limit snapshot from `X-RateLimit-*` headers, when the response carried them. */ readonly rateLimit?: RateLimit; constructor(status: number, code: string, message?: string, extra?: ApiErrorExtra); } /** * Raised on a `422 DRIFT_ACTIVE` from `POST /v1/underwriting/policy/bind`: * the resolved cell has an open warning/critical L9 drift event, so the bind * is refused (a watch-level event is a soft `driftAdvisories` on success, not * an error). Subclasses `GoableApiError`, so existing `instanceof * GoableApiError` / `.code === "DRIFT_ACTIVE"` checks keep working. */ export declare class DriftActiveError extends GoableApiError { readonly name = "DriftActiveError"; /** The blocking cells, from the server's `detail.openDriftEvents`. Shape is * per-cell and best-effort (documented, not part of the typed contract). */ readonly openDriftEvents: Array>; constructor(status: number, code: string, message?: string, extra?: ApiErrorExtra); } export declare class GoableNetworkError extends Error { readonly name = "GoableNetworkError"; /** "timeout" when the request was aborted by the configured timeout. */ readonly kind: "timeout" | "network" | "parse"; readonly cause?: unknown; constructor(message: string, kind: "timeout" | "network" | "parse", cause?: unknown); } /** A minimal read-only header bag (the `headers` of a fetch Response). */ export interface HeaderBag { get(name: string): string | null; } /** Map a parsed error body + status into a GoableApiError. Tolerant of a * non-conforming body (falls back to the status code as the error code). * When `headers` are supplied, surfaces `Retry-After` (as `retryAfterSeconds`) * and the `X-RateLimit-*` snapshot on the resulting error. */ export declare function toApiError(status: number, body: unknown, headers?: HeaderBag): GoableApiError; //# sourceMappingURL=errors.d.ts.map