Error thrown when retry attempts are exhausted

Thrown by the retry middleware when all retry attempts have been exhausted. Includes the number of attempts made and the last error encountered.

Example

import { createFej, createRetryMiddleware, FejRetryError } from 'fej';

const api = createFej();
api.use('retry', createRetryMiddleware({ attempts: 3 }));

try {
await api.fej('/api/unreliable-endpoint');
} catch (error) {
if (error instanceof FejRetryError) {
console.error(`Failed after ${error.attempts} attempts`);
console.error('Last error:', error.lastError.message);
}
}

Hierarchy (view full)

Constructors

Properties

originalError?: Error
context?: FejContext
statusCode?: number
attempts: number
lastError: Error