/** Why a provider call failed, in terms that decide whether to retry or fall back. */ export type NexusProviderErrorCategory = 'auth' | 'abort' | 'timeout' | 'rate-limit' | 'server-error' | 'network' | 'bad-response' | 'unknown'; /** Options for constructing a `NexusProviderError`. */ export interface NexusProviderErrorOptions { /** The provider that failed. */ provider: string; /** The model requested. */ model: string; /** What went wrong. */ message: string; /** HTTP status, when the provider answered. */ status?: number; /** Why it failed. Inferred from the cause and status when omitted. */ category?: NexusProviderErrorCategory; /** Whether retrying could succeed. Inferred from the category and status when omitted. */ retryable?: boolean; /** The underlying error. */ cause?: unknown; } /** * An error from a provider call, carrying enough context to decide whether to retry or fall back. */ export declare class NexusProviderError extends Error { /** The provider that failed. */ readonly provider: string; /** The model requested. */ readonly model: string; /** HTTP status, when the provider answered. */ readonly status?: number; /** Why it failed. */ readonly category: NexusProviderErrorCategory; /** Whether retrying could succeed. */ readonly retryable: boolean; /** The underlying error. */ readonly cause?: unknown; constructor(options: NexusProviderErrorOptions); } /** * Builds an error from a failed HTTP response, including the first 1,000 characters of its body. */ export declare function createProviderHttpError(provider: string, model: string, response: Response): Promise; /** * Wraps any error as a `NexusProviderError`, inferring the status and category it does not know. A * `NexusProviderError` is returned unchanged. */ export declare function toNexusProviderError(error: unknown, context: Pick & Partial): NexusProviderError; /** An error for a request the caller aborted. Never retryable. */ export declare function createAbortProviderError(provider: string, model: string, cause?: unknown): NexusProviderError; /** An error for a request that ran past its timeout. Retryable. */ export declare function createTimeoutProviderError(provider: string, model: string, timeoutMs: number): NexusProviderError; /** Categorizes an error from its HTTP status, then from its name, code, and message. */ export declare function categorizeProviderError(error: unknown, status?: number): NexusProviderErrorCategory; /** * Whether a category of failure is worth retrying: timeouts, rate limits, server errors, and * network failures are. */ export declare function isRetryableProviderError(category: NexusProviderErrorCategory, status?: number): boolean; /** Whether an error is an abort, by its name, its code, or its message. */ export declare function isAbortError(error: unknown): boolean;