DocsError simulation
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:

  1. Check the HTTP status code
  2. Parse the error response body
  3. Retry if appropriate (for 503, 429)
  4. 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
}