Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • RetryOperation

Index

Methods

attempt

  • Defines the function that is to be retried and executes it for the first time right away.

    Parameters

    • fn: function

      The function that is to be retried. currentAttempt represents the number of attempts callback has been executed so far.

        • (currentAttempt: number): void
        • Parameters

          • currentAttempt: number

          Returns void

    • Optional timeoutOps: AttemptTimeoutOptions

    Returns void

attempts

  • attempts(): number
  • Returns an int representing the number of attempts it took to call fn before it was successful.

    Returns number

errors

  • errors(): Error[]
  • Returns an array of all errors that have been passed to retryOperation.retry() so far. The returning array has the errors ordered chronologically based on when they were passed to retryOperation.retry(), which means the first passed error is at index zero and the last is at the last index.

    Returns Error[]

mainError

  • mainError(): Error | null
  • A reference to the error object that occured most frequently. Errors are compared using the error.message property. If multiple error messages occured the same amount of time, the last error object with that message is returned.

    Returns Error | null

    If no errors occured so far the value will be null.

reset

  • reset(): void
  • Resets the internal state of the operation object, so that you can call attempt() again as if this was a new operation object.

    Returns void

retry

  • retry(err?: Error): boolean
  • Returns false when no error value is given, or the maximum amount of retries has been reached. Otherwise it returns true, and retries the operation after the timeout for the current attempt number.

    Parameters

    Returns boolean

stop

  • stop(): void
  • Stops the operation being retried. Useful for aborting the operation on a fatal error etc.

    Returns void

Generated using TypeDoc