@ExceptionHandler

The Spring annotation that marks a method to handle a particular exception type thrown by controllers and turn it into a response.

In more detail

Placed in controller advice, it applies to every controller. The course handler turns an OrderMissing exception into a 404 problem detail.

Example

@ExceptionHandler(OrderMissing.class) ProblemDetail missing(OrderMissing error)

Related terms

Taught in

References