Skip to main content

RetryErrorHandling

Upgather SDK


Upgather SDK / RetryErrorHandling

Class: RetryErrorHandling

Defined in: lib/error/RetryErrorHandling.ts:138

Provides an error handling strategy that supports retries with exponential backoff.

Remarks

This class implements the ErrorHandlingStrategy interface and allows for retrying failed API calls with configurable backoff, jitter, and retry conditions.

Implements

Constructors

new RetryErrorHandling()

new RetryErrorHandling(maxRetries, options): RetryErrorHandling

Defined in: lib/error/RetryErrorHandling.ts:163

Creates an instance of RetryErrorHandling.

Parameters

maxRetries

number

The maximum number of retry attempts.

options

RetryErrorHandlingOptions = {}

Configuration options for retry behavior.

Returns

RetryErrorHandling

Methods

getRetryDelay()

getRetryDelay(attempt): number

Defined in: lib/error/RetryErrorHandling.ts:260

Calculates the delay for a given attempt with exponential backoff and jitter.

Parameters

attempt

number

The current attempt number.

Returns

number

The delay in milliseconds.


handleError()

handleError(response, attempt, originalError): ErrorHandlingResult

Defined in: lib/error/RetryErrorHandling.ts:216

Handles the API error by implementing a retry mechanism.

Parameters

response

ApiResponse

The API response containing error details.

attempt

number

The current attempt number.

originalError

Error

The original error that occurred.

Returns

ErrorHandlingResult

An ErrorHandlingResult indicating whether to retry or abort.

Implementation of

ErrorHandlingStrategy.handleError


isRetryableStatusCode()

isRetryableStatusCode(statusCode): boolean

Defined in: lib/error/RetryErrorHandling.ts:301

Determines if a status code represents a retryable error.

Parameters

statusCode

number

The HTTP status code to check.

Returns

boolean

True if the status code represents a retryable error, false otherwise.


shouldRetry()

shouldRetry(statusCode, attempt, response): boolean

Defined in: lib/error/RetryErrorHandling.ts:280

Determines whether a request should be retried.

Parameters

statusCode

number

The HTTP status code.

attempt

number

The current attempt number.

response

ApiResponse

The full API response.

Returns

boolean

True if the request should be retried, false otherwise.