Lesson 2.3

Error handling and problem details

One error shape across every endpoint means a client writes error handling once.

9mBeginner16.4k students

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

Previous Lesson
Next Lesson
Error handling and problem details — API Design with Node.js — Vertex