Overview
Proper error handling ensures your application remains resilient and provides a great user experience even when issues occur. This guide covers common errors, best practices, and implementation patterns.HTTP Status Codes
The Fraudiant API uses standard HTTP status codes to indicate success or failure:| Status Code | Meaning | Description |
|---|---|---|
200 | Success | Request completed successfully |
400 | Bad Request | Invalid input (malformed email, invalid domain) |
401 | Unauthorized | Missing or invalid API key |
403 | Forbidden | Feature requires Pro account or insufficient permissions |
404 | Not Found | Resource not found (e.g., domain not in blocklist) |
422 | Unprocessable Entity | Validation failed (e.g., duplicate blocklist entry) |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Unexpected server error |
503 | Service Unavailable | Temporary service outage |
Common Error Responses
Invalid Email (400)
Returned when the email address format is invalid:Unauthorized (401)
Returned when API key is missing, invalid, or expired:- Missing
Authorizationheader - Invalid API key format
- Expired or revoked API key
- Typo in API key
Pro Feature Required (403)
Returned when attempting to use Pro-only features (like blocklist management):Rate Limit Exceeded (429)
Returned when you exceed your rate limit:Service Unavailable (503)
Returned during temporary service outages:Network & Timeout Errors
Timeout Handling
Connection Errors
Error Logging & Monitoring
Structured Error Logging
Circuit Breaker Pattern
Prevent cascading failures by implementing a circuit breaker:Error Recovery Strategies
Graceful Degradation
Queue Failed Requests
Testing Error Scenarios
Mock Error Responses
Best Practices Summary
Always implement timeout handling
Always implement timeout handling
Set reasonable timeouts (3-5 seconds) to prevent hanging requests.
Fail open, not closed
Fail open, not closed
When errors occur, allow users to proceed rather than blocking them completely.
Log errors with context
Log errors with context
Include request metadata, timestamps, and error details for debugging.
Implement retry logic
Implement retry logic
Use exponential backoff for transient failures like rate limits and network issues.
Monitor error rates
Monitor error rates
Track error patterns to identify systemic issues early.
Test error scenarios
Test error scenarios
Use mocks to test how your application handles various error conditions.