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
| Class | Entry point | When thrown |
|---|---|---|
RetryerConfigError | axios-retryer | Invalid option combination in createRetryer() |
PluginRegistrationError | axios-retryer | Duplicate plugin name or invalid plugin object |
QueueFullError | axios-retryer | maxQueueSize exceeded |
QueuedRequestCanceledError | axios-retryer | Request cancelled while waiting in queue |
QueueClearedError | axios-retryer | Queue cleared (e.g. by destroy()) |
QueueDestroyedError | axios-retryer | Manager destroyed before request could be processed |
RequestAbortedError | axios-retryer | Request aborted via AbortController |
InvalidCacheKeyError | CachingPlugin | Unable to build a stable cache key |
CircuitBreakerStateError | CircuitBreakerPlugin | Request blocked because circuit is open |
MissingTokenRefreshHandlerError | TokenRefreshPlugin | No refresh callback provided |
TokenRefreshAbortError | TokenRefreshPlugin | Refresh callback threw before making the request |
TokenRefreshFailedError | TokenRefreshPlugin | Refresh request failed after all attempts |
TokenRefreshTimeoutError | TokenRefreshPlugin | Refresh request exceeded the timeout |