Start here. This is the direct spoken answer to practice first.
Why this question matters
Design API error handling across validation errors, conflicts, auth failures, not-found responses, and unexpected exceptions. It matters in real backend work because the server has to enforce trust boundaries even when the UI, client, or caller behaves unexpectedly. The practical angle is error contracts, ProblemDetails, exception boundaries, safe logging, client behavior, and retry semantics, tied to a concrete production decision.
I use one error-handling boundary to translate known failures into consistent HTTP responses. Validation, not-found, conflict, authorization, rate-limit, and unexpected failures each have a deliberate status and machine-readable code. Controllers return normal results or raise known application failures instead of building ad hoc error objects. Unexpected exceptions are logged and returned as safe generic problems.