Create a new ApiError instance
Categorized error code for programmatic handling
HTTP status code (0 for network errors)
Human-readable error description
Optionalresponse: Response | ApiResponseOriginal response object (if available)
Optionalrequest: ApiRequestOriginal request object that caused the error
ReadonlytimestampTimestamp when the error occurred (milliseconds since epoch)
ReadonlycodeCategorized error code for programmatic handling
ReadonlystatusHTTP status code (0 for network errors)
Optional ReadonlyresponseOriginal response object (if available)
Optional ReadonlyrequestOriginal request object that caused the error
Check if error is retryable based on error type and status code
True if the error should be retried, false otherwise
Serialize error details to JSON for logging and debugging
Object containing error details suitable for JSON serialization
StaticfromCreate ApiError from HTTP response
The HTTP response that indicates failure
Optionalrequest: ApiRequestThe original request that generated this response
New ApiError instance with HTTP_ERROR code
StaticfromCreate ApiError for timeout scenarios
Optionalrequest: ApiRequestThe request that timed out
New ApiError instance with TIMEOUT code
StaticfromCreate ApiError for network failures
The original network error
Optionalrequest: ApiRequestThe request that failed
New ApiError instance with NETWORK_ERROR code
StaticfromCreate ApiError for aborted requests
Optionalrequest: ApiRequestThe request that was aborted
New ApiError instance with ABORTED code
StaticfromCreate ApiError for response parsing failures
The type of data that failed to parse (e.g., 'json', 'text')
HTTP status code of the response
The original parsing error
Optionalresponse: ApiResponseThe response that failed to parse
Optionalrequest: ApiRequestThe request that generated this response
New ApiError instance with specific parse error code
Enhanced API error with detailed context and debugging information
Description
Extends the native Error class to provide comprehensive error information for API failures. Includes error categorization, retry detection, and debugging context.
Example