Design a comprehensive REST API error handling system for [FRAMEWORK: Express / Fastify / Django / Rails / Spring].
Provide:
1. **Error Response Format**: Consistent JSON structure for all errors
2. **HTTP Status Code Guide**: When to use each code (400, 401, 403, 404, 409, 422, 429, 500, 503)
3. **Custom Error Classes**: Hierarchy of error types with codes
4. **Validation Errors**: How to format field-level validation errors
5. **Global Error Middleware**: Catch-all handler implementation
6. **Logging Integration**: What to log for each error type
7. **Rate Limiting Errors**: Headers and response format
8. **Authentication Errors**: Token expired, invalid, missing — different responses
9. **Client-Friendly Messages**: User-facing vs developer-facing error messages
10. **Complete Code**: Full implementation with examples
Design a comprehensive REST API error handling system for [FRAMEWORK: Express / Fastify / Django / Rails / Spring].
Provide:
1. **Error Response Format**: Consistent JSON structure for all errors
2. **HTTP Status Code Guide**: When to use each code (400, 401, 403, 404, 409, 422, 429, 500, 503)
3. **Custom Error Classes**: Hierarchy of error types with codes
4. **Validation Errors**: How to format field-level validation errors
5. **Global Error Middleware**: Catch-all handler implementation
6. **Logging Integration**: What to log for each error type
7. **Rate Limiting Errors**: Headers and response format
8. **Authentication Errors**: Token expired, invalid, missing — different responses
9. **Client-Friendly Messages**: User-facing vs developer-facing error messages
10. **Complete Code**: Full implementation with examples
How to use this prompt
Copy the prompt above and paste it into ChatGPT, Claude, Gemini, or any AI assistant. Replace the bracketed placeholders with your specific details.
Leave a Review
Tried this prompt? Let us know how it worked — your reviews help other users find the best prompts.