/** * One vocabulary for adapter failures, so code above an adapter retries, alerts, and reports the same * way whichever database, provider, or service the adapter talks to. */ /** What kind of failure an adapter call met. */ export type AdapterErrorCode = 'AUTH' | 'RATE_LIMIT' | 'NOT_FOUND' | 'INVALID' | 'CONFLICT' | 'TIMEOUT' | 'UNAVAILABLE' | 'CANCELLED' | 'UNKNOWN'; /** A failure's code, and whether another attempt could succeed. */ export interface AdapterErrorClass { /** The kind of failure. */ code: AdapterErrorCode; /** True for a failure a retry could get past: a rate limit, a timeout, an unavailable service. */ retryable: boolean; /** The HTTP status, when the failure carried one. */ status?: number; } /** A failed adapter call, normalized. The original error is its `cause`. */ export declare class AdapterError extends Error { /** The adapter that failed. */ readonly adapter: string; /** The method that failed, such as `search`. */ readonly operation: string; /** The kind of failure. */ readonly code: AdapterErrorCode; /** Whether another attempt could succeed. */ readonly retryable: boolean; /** The HTTP status, when the failure carried one. */ readonly status?: number; constructor( /** The adapter that failed. */ adapter: string, /** The method that failed, such as `search`. */ operation: string, failure: AdapterErrorClass, cause: unknown); } /** * Classifies any error by what it carries: an HTTP status (`status`, `statusCode`, or * `response.status`), a Node network code such as `ECONNREFUSED`, or an `AbortError` or * `TimeoutError` name. An adapter's own `normalizeError` runs first and may override it. */ export declare function classifyAdapterError(error: unknown): AdapterErrorClass;