Error Handling
Comprehensive guide to API errors and recovery strategies.Response Format
All error responses follow a standard format:HTTP Status Codes
4xx Client Errors
400 Bad Request
Invalid request format or parameters. When: Missing required fields, invalid data types, malformed JSON401 Unauthorized
Invalid or missing API key. When: No auth header, invalid key format, expired token403 Forbidden
Valid auth but insufficient permissions. When: Non-admin accessing admin endpoint, user accessing another user’s job404 Not Found
Resource doesn’t exist. When: Tool not found, job doesn’t exist, server not registered429 Too Many Requests
Rate limit exceeded. When: Too many requests in short time period5xx Server Errors
500 Internal Server Error
Unexpected server error. When: Bug in API, database error, service failure504 Gateway Timeout
Tool execution exceeded timeout. When: Tool takes too long to respondError Codes Reference
Authentication Errors
Request Errors
Resource Errors
Execution Errors
Rate Limiting
Server Errors
Error Handling Patterns
Try-Catch
Promise.catch()
With Logging
Status Code Decisions
When to Retry
Always retry:- 429 (Rate limited) - with exponential backoff
- 503 (Service unavailable) - with exponential backoff
- 504 (Timeout) - convert to job and poll
- 500 (Internal error) - with limit (max 3x)
- 400 (Bad request) - fix parameters
- 401 (Unauthorized) - check API key
- 403 (Forbidden) - check permissions
- 404 (Not found) - resource doesn’t exist
Rate Limit Recovery
Headers Check
Adaptive Rate Limiting
Common Mistakes
❌ Not Handling 429
✅ Correct - Queue with Rate Limiting
❌ Not Checking Error Code
✅ Correct - Handle by Type
Debugging Tips
Enable Request Logging
Check Request ID
Validate Before Sending
Support Resources
- API Status: https://status.agent-corex.com
- GitHub Issues: https://github.com/ankitpro/agent-corex/issues
- Documentation: https://docs.agent-corex.com
- Email Support: support@agent-corex.com