- All Courses
- API Design with Node.js
- Building the Service
- Error handling and problem details
Error handling and problem details
One error shape across every endpoint means a client writes error handling once.
Overview
Errors are part of the API
One error shape across every endpoint means a client writes error handling once. The problem details standard gives you a ready-made structure — a type, a title, a status, and a detail — so you do not have to invent one.
Four-hundred-level responses mean the client should change something; five-hundred means you should. Returning 500 for a validation failure sends clients into retry loops that cannot succeed.
Never return a stack trace or a raw database error. Log it with a correlation id and return the id, so support can find the trace without exposing your schema to the internet.
In this lesson you will:
- Return a consistent error shape
- Separate client errors from server errors
- Never leak internals in a response
Resources
Notes are not saved yet — they clear when you leave this page.
Request validation
5m
Pagination, filtering, and sorting
3m