advanced-retry
Version:
A retry library with advanced features
27 lines (26 loc) • 1.18 kB
TypeScript
import { RetryContext } from '../retry';
/**
* Function that determines if an error can be handled by the specified resolver.
*
* @param error - The error that occurred.
* @returns Whether the error can be handled.
*/
export type CanHandleErrorFunction<X> = (error: unknown, attempt: number, context: RetryContext<X>) => boolean;
/**
* Base interface for error filters
*/
export interface ErrorFilter<X> {
canHandleError: CanHandleErrorFunction<X>;
}
export declare function toErrorFilter<X>(p: CanHandleErrorFunction<X> | ErrorFilter<X>): ErrorFilter<X>;
/**
* Creates a filter that requires all provided filters to pass
* @param filters Array of filters or filter functions
*/
export declare function allErrorFilter<X>(filters: (ErrorFilter<X> | CanHandleErrorFunction<X>)[]): ErrorFilter<X>;
/**
* Creates a filter that requires any of the provided filters to pass
* @param filters Array of filters or filter functions
*/
export declare function anyErrorFilter<X>(filters: (ErrorFilter<X> | CanHandleErrorFunction<X>)[]): ErrorFilter<X>;
export declare function noneErrorFilter<X>(filters: (ErrorFilter<X> | CanHandleErrorFunction<X>)[]): ErrorFilter<X>;