Magek Framework
    Preparing search index...

    Function retryIfError

    • Retries an async function if it fails with an error that matches the given class.

      Type Parameters

      • TReturn

      Parameters

      • logicToRetry: (tryNumber?: number) => Promise<TReturn>

        Async function to retry

      • errorClassThatRetries: Class<Error>

        Error class. If the async function fails with an error that matches this class, it will be retried.

      • Optionallogger: Logger

        Logger to use for logging. If not provided, no logging will be performed.

      • maxRetries: number = 1000

        Maximum number of retries. If not provided, the default is 1000.

      Returns Promise<TReturn>

      The result of the first successful retry.