12.8. Exception Handling

12.8.1. Create an Exception Mapper


Exception mappers are custom, application provided components that catch thrown exceptions and write specific HTTP responses.

Example 12.2. Exception Mapper

An exception mapper is a class that is annotated with the @Provider annotation, and implements the ExceptionMapper interface.
An example exception mapper is shown below.
public class EJBExceptionMapper implements ExceptionMapper<javax.ejb.EJBException>
    Response toResponse(EJBException exception) {
    return Response.status(500).build();
To register an exception mapper, list it in the web.xml file under the resteasy.providers context-param, or register it programatically through the ResteasyProviderFactory class.