Docs

Error Classes

Library-thrown errors use named classes so you can handle them with instanceof instead of string matching.

Core errors

Exported from axios-retryer:

import {
  RetryerConfigError,        // Invalid RetryManager configuration
  PluginRegistrationError,   // Duplicate or invalid plugin registration
  QueueFullError,            // maxQueueSize exceeded
  QueuedRequestCanceledError, // Request was in queue when cancelled
  QueueClearedError,         // Queue was cleared (e.g. destroy())
  QueueDestroyedError,       // Manager was destroyed before request processed
  RequestAbortedError,       // Request aborted via AbortController
} from 'axios-retryer';

Plugin errors

Exported from their respective plugin entry points:

// CachingPlugin
import { InvalidCacheKeyError } from 'axios-retryer/plugins/CachingPlugin';

// CircuitBreakerPlugin
import { CircuitBreakerStateError } from 'axios-retryer/plugins/CircuitBreakerPlugin';

// TokenRefreshPlugin
import {
  MissingTokenRefreshHandlerError,
  TokenRefreshAbortError,
  TokenRefreshFailedError,
  TokenRefreshTimeoutError,
} from 'axios-retryer/plugins/TokenRefreshPlugin';

Handling errors by type

import {
  QueueFullError,
  RetryerConfigError,
  PluginRegistrationError,
} from 'axios-retryer';
import {
  TokenRefreshAbortError,
  TokenRefreshTimeoutError,
} from 'axios-retryer/plugins/TokenRefreshPlugin';
import { CircuitBreakerStateError } from 'axios-retryer/plugins/CircuitBreakerPlugin';

try {
  await retryer.axiosInstance.get('/api/data');
} catch (error) {
  if (error instanceof QueueFullError) {
    // Show backpressure UI
    showToast('Server busy — please try again shortly');
  } else if (error instanceof CircuitBreakerStateError) {
    // Circuit tripped open
    showBanner('Service temporarily unavailable');
  } else if (error instanceof TokenRefreshAbortError) {
    // Auth refresh failed fatally
    redirectToLogin();
  } else if (error instanceof TokenRefreshTimeoutError) {
    // Refresh request took too long
    scheduleRetry();
  } else {
    throw error;  // Re-throw unrecognized errors
  }
}

Error reference

ClassEntry pointWhen thrown
RetryerConfigErroraxios-retryerInvalid option combination in createRetryer()
PluginRegistrationErroraxios-retryerDuplicate plugin name or invalid plugin object
QueueFullErroraxios-retryermaxQueueSize exceeded
QueuedRequestCanceledErroraxios-retryerRequest cancelled while waiting in queue
QueueClearedErroraxios-retryerQueue cleared (e.g. by destroy())
QueueDestroyedErroraxios-retryerManager destroyed before request could be processed
RequestAbortedErroraxios-retryerRequest aborted via AbortController
InvalidCacheKeyErrorCachingPluginUnable to build a stable cache key
CircuitBreakerStateErrorCircuitBreakerPluginRequest blocked because circuit is open
MissingTokenRefreshHandlerErrorTokenRefreshPluginNo refresh callback provided
TokenRefreshAbortErrorTokenRefreshPluginRefresh callback threw before making the request
TokenRefreshFailedErrorTokenRefreshPluginRefresh request failed after all attempts
TokenRefreshTimeoutErrorTokenRefreshPluginRefresh request exceeded the timeout
API Reference →