controller advice

A Spring class, marked @RestControllerAdvice, whose exception handlers apply across all controllers, giving one failure policy for every route.

In more detail

Centralising exception handling stops each controller inventing its own error shape. The advice maps each domain exception to a status and a problem details body, keeps details out of the response and logs them instead.

Example

@RestControllerAdvice class ApiAdvice { ... }

Related terms

Taught in

References