export type ErrorCode = 'validation' | 'auth' | 'quota' | 'rateLimit' | 'safety' | 'provider' | 'timeout' | 'notFound' | 'serverError' | 'connection' | 'aborted' | 'unknown'; export declare const isRetryable: (code: ErrorCode) => boolean; /** * Maps the raw server-side or SDK-internal identifier into a small, stable * enum users can switch on. Server's raw identifier itself is intentionally * not exposed on `RunwareError` — the backend catalog is hundreds of strings * and unstable. Users get `code` (this enum), `parameter`, and `message` for * everything they need to react. */ export declare const deriveCode: (raw: string) => ErrorCode; export declare class RunwareError extends Error { /** Stable category for this error. Use this for switch/if statements. */ code: ErrorCode; /** True if retrying the same request might succeed. */ retryable: boolean; /** The request parameter related to the error, if applicable. */ parameter?: string; /** The task type of the request that failed. */ taskType?: string; /** The unique identifier of the failed request. */ taskUUID?: string; /** Link to relevant documentation, derived from taskType/model/parameter. */ documentation?: string; /** HTTP status code, when the error originated from an HTTP response. */ statusCode?: number; /** * Structured AJV errors describing each field that failed. * Only present when `code === 'validation'` and the failure was raised by the * opt-in client-side validator (`validate: true`). Server-side validation * errors only expose `parameter` and `message`. */ validationErrors?: unknown[]; constructor(rawCode: string, message: string); } export declare const buildDocumentationUrl: (taskType: string | undefined, model: string | undefined, parameter: string | undefined, rawCode: string) => string | undefined; type ErrorDetails = { parameter?: string | undefined; taskType?: string | undefined; taskUUID?: string | undefined; statusCode?: number | undefined; validationErrors?: unknown[] | undefined; model?: string | undefined; }; export declare const createRunwareError: (rawCode: string, message: string, details?: ErrorDetails) => RunwareError; /** * Optional request context. Server error responses often omit `taskType` and * `model` (they only echo back what the user sent in the error item itself). * The SDK knows them from the original request — pass them through so the * resulting error has a populated `taskType` and a derivable `documentation`. */ export type ErrorContext = { taskType?: string | undefined; model?: string | undefined; }; export declare const parseApiError: (raw: unknown, context?: ErrorContext) => RunwareError; export declare const isRunwareError: (error: unknown) => error is RunwareError; export {}; //# sourceMappingURL=errors.d.ts.map