T - A type of the exception processed by the exception mapper.@Singleton public abstract class AbstractErrorTemplateMapper<T extends Throwable> extends Object implements ExtendedExceptionMapper<T>
ExtendedExceptionMapper used to declare special handling for exception types that should be
processed by MVC.
Extensions should override getErrorStatus(Throwable) and getErrorModel(Throwable) to provide a response
status and model derived from a raised throwable.
By default every exception is mapped and used as a model in a viewable and passed to the MVC runtime for
further processing.| Constructor and Description |
|---|
AbstractErrorTemplateMapper() |
| Modifier and Type | Method and Description |
|---|---|
protected Object |
getErrorModel(T throwable)
Get a model for error template.
|
protected Response.Status |
getErrorStatus(T throwable)
Get a response status of to-be-processed error template.
|
boolean |
isMappable(T throwable)
Determine whether this provider is able to process a supplied exception instance.
|
Response |
toResponse(T throwable)
Map an exception to a
Response. |
public final boolean isMappable(T throwable)
ExtendedExceptionMapper
This method is called only on those exception mapping providers that are able to
process the type of the exception as defined by the JAX-RS
ExceptionMapper contract. By returning false this method can reject
any given exception instance and change the default JAX-RS exception mapper
selection behaviour.
isMappable in interface ExtendedExceptionMapper<T extends Throwable>throwable - exception instance which should be processed.true if the mapper is able to map the particular exception instance,
false otherwise.public final Response toResponse(T throwable)
ExceptionMapperResponse. Returning
null results in a Response.Status.NO_CONTENT
response. Throwing a runtime exception results in a
Response.Status.INTERNAL_SERVER_ERROR response.toResponse in interface ExceptionMapper<T extends Throwable>throwable - the exception to map to a response.protected Object getErrorModel(T throwable)
throwable itself.throwable - throwable raised during processing a resource method.protected Response.Status getErrorStatus(T throwable)
Response.Status#OK.throwable - throwable raised during processing a resource method.Copyright © 2007-2016, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.