FetchError Class
Custom error class for API request failures. Extends the native Error class with additional HTTP-specific properties.
try { await fetchData('/api/user');} catch (error) { if (error instanceof FetchError) { console.error(`HTTP ${error.status}: ${error.message}`); }} Copy
try { await fetchData('/api/user');} catch (error) { if (error instanceof FetchError) { console.error(`HTTP ${error.status}: ${error.message}`); }}
Optional
Additional error data from the API (if available)
HTTP status code (if available)
FetchError Class
Custom error class for API request failures. Extends the native Error class with additional HTTP-specific properties.
Example