Package org.onlab.rest.exceptions
Class AbstractMapper<E extends Throwable>
- java.lang.Object
-
- org.onlab.rest.exceptions.AbstractMapper<E>
-
- All Implemented Interfaces:
javax.ws.rs.ext.ExceptionMapper<E>
- Direct Known Subclasses:
BadRequestMapper
,EntityNotFoundMapper
,ForbiddenMapper
,IllegalArgumentExceptionMapper
,IllegalStateExceptionMapper
,NotFoundMapper
,ServerErrorMapper
,ServiceNotFoundMapper
,WebApplicationExceptionMapper
public abstract class AbstractMapper<E extends Throwable> extends Object implements javax.ws.rs.ext.ExceptionMapper<E>
Base exception mapper implementation.
-
-
Constructor Summary
Constructors Constructor Description AbstractMapper()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
messageFrom(Throwable exception)
Produces a response message from the supplied exception.protected javax.ws.rs.core.Response.ResponseBuilder
response(javax.ws.rs.core.Response.Status status, Throwable exception)
Produces a response builder primed with the supplied status code and JSON entity with the status code and exception message.protected abstract javax.ws.rs.core.Response.Status
responseStatus()
Returns the response status to be given when the exception occurs.javax.ws.rs.core.Response
toResponse(E exception)
-
-
-
Field Detail
-
error
protected Throwable error
Holds the current exception for use in subclasses.
-
-
Method Detail
-
responseStatus
protected abstract javax.ws.rs.core.Response.Status responseStatus()
Returns the response status to be given when the exception occurs.- Returns:
- response status
-
toResponse
public javax.ws.rs.core.Response toResponse(E exception)
-
response
protected javax.ws.rs.core.Response.ResponseBuilder response(javax.ws.rs.core.Response.Status status, Throwable exception)
Produces a response builder primed with the supplied status code and JSON entity with the status code and exception message.- Parameters:
status
- response statusexception
- exception to encode- Returns:
- response builder
-
messageFrom
protected String messageFrom(Throwable exception)
Produces a response message from the supplied exception. Either it will use the exception message, if there is one, or it will use the top stack-frame message.- Parameters:
exception
- exception from which to produce a message- Returns:
- response message
-
-