Interface ExceptionMappers
- All Known Implementing Classes:
ExceptionMapperFactory
ExceptionMapper
instances that can be used
to map exceptions to responses.- Author:
- Paul Sandoz
-
Method Summary
Modifier and TypeMethodDescription<T extends Throwable>
ExceptionMapper<T>Get an exception mapping provider for a particular class of exception.<T extends Throwable>
ExceptionMapper<T>findMapping
(T exceptionInstance) Get an exception mapping provider for a particular exception instance.
-
Method Details
-
find
Get an exception mapping provider for a particular class of exception. Returns the provider whose generic type is the nearest superclass oftype
.- Type Parameters:
T
- type of the exception handled by the exception mapping provider.- Parameters:
type
- the class of exception.- Returns:
- an
ExceptionMapper
for the supplied type ornull
if none is found.
-
findMapping
Get an exception mapping provider for a particular exception instance.This method is similar to method
find(Class)
. In addition it takes into an account the result of theExtendedExceptionMapper.isMappable(Throwable)
of any mapper that implements JerseyExtendedExceptionMapper
API. If an extended exception mapper returnsfalse
fromisMappable(Throwable)
, the mapper is disregarded from the search. Exception mapping providers are checked one by one until a first provider returnstrue
from theisMappable(Throwable)
method or until a first provider is found which best supports the exception type and does not implementExtendedExceptionMapper
API (i.e. it is a standard JAX-RSExceptionMapper
). The order in which the providers are checked is determined by the distance of the declared exception mapper type and the actual exception type.Note that if an exception mapping provider does not implement
ExtendedExceptionMapper
it is always considered applicable for a given exception instance.- Type Parameters:
T
- type of the exception handled by the exception mapping provider.- Parameters:
exceptionInstance
- exception to be handled by the exception mapping provider.- Returns:
- an
ExceptionMapper
for the supplied exception instance type ornull
if none is found.
-