Chapter 24. Exception Handling
24.1. Exception Mappers Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
ExceptionMappers are custom, application-provided components that can catch application exceptions and write specific HTTP responses. They are associated with @Provider, and implement the following interface:
When an application throws an exception, the exception is caught by the JAX-RS runtime. JAX-RS then scans registered
ExceptionMappers to locate one which supports marshalling the exception type thrown. An example ExceptionMapper follows:
ExceptionMappers are registered in the same way as MessageBodyReaders and MessageBodyWriters: by scanning through the RESTEasy provider context-param (if you are deploying in a WAR file), or programmatically through the ResteasyProviderFactory class.