05 / 05
Error simulation
How mock APIs simulate errors and edge cases.
Error types
Mock APIs can simulate various error conditions to test your error handling:
- 404 Not Found - Resource doesn't exist
- 400 Bad Request - Invalid request format
- 429 Rate Limited - Too many requests
- 500 Server Error - Internal server error
- 503 Service Unavailable - Temporary outage
Test-specific errors
Some briefs inject errors on specific test cases to verify your error handling:
Error injection
Test case 3 might always return 503 to test retry logic. Check the brief instructions for details on expected error handling.
Handling errors
When an API call fails, your workflow should:
- Check the HTTP status code
- Parse the error response body
- Retry if appropriate (for 503, 429)
- Return an appropriate error response to the callback
json
// Example error response from mock API
{
"error": "Service temporarily unavailable",
"code": "SERVICE_UNAVAILABLE",
"retry_after": 5
}