API Error Types
Error types
There are three types of errors that you can receive: client_error
, validation_error
and server_error
.
Client errors
Client errors are indicated by the 4xx series of status codes in HTTP responses. These errors suggest that the request made was somehow incorrect or not fulfillable. Common reasons include:
400 Bad Request: The request was malformed or cannot be processed by the server.
401 Unauthorized: The request lacks valid authentication credentials.
403 Forbidden: The server understood the request but refuses to authorize it.
404 Not Found: The requested resource was not found on the server.
It will be in the form:
{
"success": false,
"error": {
"type": "client_error",
"detail": {
"code": "bad_request",
"message": "User already exists."
}
}
}
Validation errors
Validation errors are a specific subset of client errors and are part of the broader 400 Bad Request category. These occur when the data submitted fails to meet the validation rules set by the server. For example:
- Form submissions with missing fields.
- Input data that does not adhere to expected formats (e.g., email address).
- Posting data that fails to meet requirements (e.g., passwords not matching password policies).
{
"success": false,
"error": {
"type": "validation_error",
"detail": {
"code": "invalid",
"message": "Enter a valid email address.",
"field_name": "email"
}
}
}
Server errors
Server errors are indicated by the 5xx series of status codes in HTTP responses. We will be notified immediately when these occur.
{
"success": false,
"error": {
"type": "server_error",
"detail": {
"code": "error",
"message": "Something went wrong, we are on top of it!"
}
}
}
Updated 9 months ago