One Error Shape for the Whole API

Every error an API sends can have one JSON shape, modeled on RFC 9457's problem details (a status, a title, a detail sentence and, on a 422, a list of field problems), built by one problem() function and sent by an exception handler for each kind of error, FastAPI's own 404 and 422 included, with a catch-all that answers a crash with a calm 500 and never a traceback.

By

Updated

Cheat sheet: One Error Shape for the Whole API
Category
FastAPI
Level
Journeyman
Tags
422 Unprocessable Content, 500 Internal Server Error, fastapi, Problem Details, RequestValidationError, rest-api, Traceback