import { serverLogger } from "../utils/logger/logger.js"; export declare function handleErrorWithFallback(fn: () => T | Promise, fallback: T, logger?: typeof serverLogger): Promise; export declare function handleErrorWithFallbackSync(fn: () => T, fallback: T, logger?: typeof serverLogger): T; /** * Options for {@link retryWithBackoff}. Every `attempt` value passed to `fn` * and the hooks below is 0-based (first try = 0), including * `wrapFinalError`'s `lastAttempt`. */ export interface RetryWithBackoffOptions { /** Total number of attempts (first try included). */ maxAttempts?: number; /** Cancels the active attempt and any pending backoff delay. */ abortSignal?: AbortSignal; initialDelay?: number; maxDelay?: number; logger?: typeof serverLogger; /** * Per-attempt timeout: aborts the attempt's AbortSignal with an AbortError. * Cooperative - the attempt only stops if `fn` observes the signal it is given. */ timeoutMs?: number; /** Return false to rethrow immediately without further attempts (default: always retry). */ shouldRetry?: (error: unknown, attempt: number) => boolean; /** Override the exponential backoff delay for the wait after `attempt`. */ computeDelay?: (attempt: number, error: unknown) => number; /** * Called before each backoff wait; replaces the default warn log. * `isTimeout` reports whether this helper's per-attempt timer aborted the * signal, independent of the error type ultimately thrown by `fn`. */ onRetry?: (info: { error: Error; attempt: number; delay: number; isTimeout: boolean; }) => void; /** * Wrap the terminal error once all attempts are exhausted. Default: rethrow * the normalized Error (non-Error throws become `new Error(String(value))`). */ wrapFinalError?: (lastError: Error, lastAttempt: number) => Error; } export declare function retryWithBackoff(fn: (signal: AbortSignal | undefined, attempt: number) => Promise, options?: RetryWithBackoffOptions): Promise; //# sourceMappingURL=error-handlers.d.ts.map