Error Types
CallApi distinguishes between three main error types:- HTTPError - Server responded with an error status code (4xx, 5xx)
- ValidationError - Request/response validation failed
- JavaScriptError - Network errors, timeouts, or other JavaScript errors
isHTTPError
Checks if an error is an HTTP error from the server.Import
Signature
Usage
HTTPError Properties
WhenisHTTPError returns true, the error has these properties:
isValidationError
Checks if an error is a validation error.Import
Signature
Usage
ValidationError Properties
WhenisValidationError returns true, the error has these properties:
isJavascriptError
Checks if an error is a JavaScript error (network error, timeout, etc.).Import
Signature
Usage
Common JavaScript Errors
- AbortError: Request was aborted or timed out
- TypeError: Network error, CORS issue, or fetch failed
- Error: Generic JavaScript error
Class Instance Checkers
CallApi also provides checkers for error class instances:isHTTPErrorInstance
isValidationErrorInstance
Complete Error Handling Example
With Hooks
Use error type guards in lifecycle hooks:Type Safety
All error helpers provide full TypeScript type narrowing:See Also
- Error Handling Guide - Comprehensive error handling patterns
- Hooks - Using error hooks