💻 Coding & Development Prompts

Python, JavaScript, SQL, debugging, API

← All Categories
1 prompts in Backend

API Error Handling Best Practices

coding Backend Intermediate
Show me how to implement proper error handling for a REST API in [Node.js/Python/your language]. Include: 1) Custom error class hierarchy, 2) Global error handler middleware, 3) Specific handlers for: validation errors (400), authentication errors (401), authorization errors (403), not found (404), rate limiting (429), server errors (500), 4) Consistent error response format (JSON), 5) Error logging with stack traces (not sent to client), 6) Different behavior for development vs production.
💡 Never expose stack traces or internal error details to the client in production.