Show Table of Contents
12.8. Exception Handling
12.8.1. Create an Exception Mapper
Summary
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.
@Provider
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 programmatically through the ResteasyProviderFactory class.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.