Start here. This is the direct spoken answer to practice first.
Overview
Consistency comes from classifying failures, not from turning every exception into the same JSON object.
I define a small public error envelope and register FastAPI exception handlers for the failure categories that cross the HTTP boundary. Request-validation failures become client errors with safe field locations; deliberate HTTPException values preserve their status and required headers; domain outcomes map to documented application error identities; and unexpected exceptions return a generic server error. Internal logs and traces keep the original exception and correlation data without exposing stack traces, SQL, or secrets to the client.