Base error class for all Fej-related errors

Extends the native Error class with additional context about the failed request. All Fej errors include optional request context and original error information.

Example

import { FejError } from 'fej';

try {
await api.fej('/api/users');
} catch (error) {
if (error instanceof FejError) {
console.error('Request failed:', error.message);
console.error('Status code:', error.statusCode);
console.error('URL:', error.context?.request.url);
}
}

Hierarchy (view full)

Constructors

  • Parameters

    • message: string
    • Optional originalError: Error
    • Optional context: FejContext
    • Optional statusCode: number

    Returns FejError

Properties

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