Error handlingmedium3-5 years
What's wrong with Spring Boot's default error response, and how does RFC 9457 Problem Details fix it?
Spring's default body for a failed @Valid request is {"timestamp":...,"status":400,"error":"Bad Request","path":...} — it says nothing about which field failed or why, so a form can't highlight anything and a support ticket says only "it says bad request". Problem Details (RFC 9457, obsoletes RFC 7807) is a standard shape — type, title, status, detail, instance, plus extra members — sent as application/problem+json. A single @RestControllerAdvice with @ExceptionHandler methods produces it for every endpoint without touching a controller, and clients that already understand the format need no special-casing per service.