Error Handling
Gale returns consistent and descriptive error responses across all endpoints to help you debug and recover gracefully.Standard Error Format
All errors follow this format:HTTP Status Codes
| Status Code | Error Code | Meaning | When It Happens |
|---|---|---|---|
| 400 | bad_request | Bad Request | Malformed JSON or missing required fields |
| 401 | unauthorized | Unauthorized | Missing or invalid API key |
| 403 | forbidden | Forbidden | Valid token but insufficient permissions |
| 404 | not_found | Not Found | Resource does not exist |
| 409 | conflict | Conflict | Invalid state change |
| 422 | validation_error | Validation Failed | Field validation failed |
| 429 | rate_limit_exceeded | Too Many Requests | Rate limit exceeded |
| 500 | internal_error | Server Error | Something went wrong on Gale’s side |
Error Examples
Validation Error (422)
Unauthorized (401)
Not Found (404)
Rate Limited (429)
Retry-After header indicating seconds to wait.
Best Practices
- Check status code first: Use HTTP status codes to determine error type
- Parse error details: Check
error.details.field_errorsfor specific validation failures - Implement retry logic: For 429 and 500 errors, retry with exponential backoff
- Log errors: Store error responses for debugging
Related
- Authentication - API key setup
- Rate Limits - Handling rate limits
