/** * Simple error handling system for Replicate API. */ /** * Base class for all Replicate API errors. */ export declare class ReplicateError extends Error { context?: Record | undefined; constructor(message: string, context?: Record | undefined); } export declare const createError: { rateLimit: (retryAfter: number) => ReplicateError; authentication: (details?: string) => ReplicateError; notFound: (resource: string) => ReplicateError; api: (status: number, message: string) => ReplicateError; prediction: (id: string, message: string) => ReplicateError; validation: (field: string, message: string) => ReplicateError; timeout: (operation: string, ms: number) => ReplicateError; }; interface RetryOptions { maxAttempts?: number; minDelay?: number; maxDelay?: number; backoffFactor?: number; retryIf?: (error: Error) => boolean; onRetry?: (error: Error, attempt: number) => void; } /** * Error handling utilities. */ export declare const ErrorHandler: { /** * Check if an error should trigger a retry. */ isRetryable(error: Error): boolean; /** * Calculate delay for exponential backoff. */ getBackoffDelay(attempt: number, { minDelay, maxDelay, backoffFactor, }?: Partial): number; /** * Execute an operation with automatic retries. */ withRetries(operation: () => Promise, optionsOrMaxAttempts?: RetryOptions | number): Promise; /** * Parse error from API response. */ parseAPIError(response: Response): Promise; /** * Create a detailed error report. */ createErrorReport(error: Error): { name: string; message: string; context?: Record; timestamp: string; }; }; export {};