UrbanReflex Logo
UrbanReflex

Error Handling

Error codes and debugging

Error Handling

HTTP Status Codes

CodeDescription
200Success
400Bad Request
401Unauthorized
403Forbidden
404Not Found
429Rate Limited
500Server Error

Error Format

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid parameters",
    "details": {"field": "email", "issue": "Invalid format"},
    "request_id": "req_abc123"
  }
}

Error Codes

CodeDescription
VALIDATION_ERRORInput validation failed
AUTHENTICATION_ERRORAuth failed
NOT_FOUNDResource not found
RATE_LIMIT_EXCEEDEDToo many requests

Handling Errors

try:
    data = await api_call("/users/me")
except APIError as e:
    if e.code == "AUTHENTICATION_ERROR":
        # Redirect to login
        pass
    elif e.code == "RATE_LIMIT_EXCEEDED":
        # Wait and retry
        pass

Debugging

# Check health
curl http://localhost:8000/health
 
# Enable debug mode in .env
DEBUG=true
LOG_LEVEL=DEBUG

On this page