public class UniversalExceptionMapper extends Object
Supports both, JAX-RS responses and Servlet API responses.
2 additional aspects are handled: - Logging the exception. - Enriching the response with an error entity.
Modifier and Type | Class and Description |
---|---|
private static class |
UniversalExceptionMapper.ExceptionInfo |
Modifier and Type | Field and Description |
---|---|
private Throwable |
e |
private Logger |
logger |
private static javax.ws.rs.core.Response.StatusType |
METHOD_NOT_ALLOWED |
private javax.servlet.http.HttpServletRequest |
request |
Constructor and Description |
---|
UniversalExceptionMapper(Throwable e,
javax.servlet.http.HttpServletRequest request) |
Modifier and Type | Method and Description |
---|---|
private javax.ws.rs.core.Response |
errorResponse(javax.ws.rs.core.Response.ResponseBuilder builder,
Throwable e) |
private javax.ws.rs.core.Response.StatusType |
fromStatusCode(int statusCode) |
private boolean |
hasNestedAccessControlException(Throwable e) |
void |
initResponse(javax.servlet.http.HttpServletResponse response) |
private void |
logException(javax.ws.rs.core.Response.StatusType status,
Throwable e) |
javax.ws.rs.core.Response |
toResponse() |
private void |
transferResponse(javax.ws.rs.core.Response response,
javax.servlet.http.HttpServletResponse servletResponse)
Transfers status code, headers, and entity of a JAX-RS Response to a HttpServletResponse and sends the response.
|
private static javax.ws.rs.core.Response.StatusType METHOD_NOT_ALLOWED
private javax.servlet.http.HttpServletRequest request
public UniversalExceptionMapper(Throwable e, javax.servlet.http.HttpServletRequest request)
public javax.ws.rs.core.Response toResponse()
public void initResponse(javax.servlet.http.HttpServletResponse response) throws IOException
IOException
private void logException(javax.ws.rs.core.Response.StatusType status, Throwable e)
private javax.ws.rs.core.Response errorResponse(javax.ws.rs.core.Response.ResponseBuilder builder, Throwable e)
private boolean hasNestedAccessControlException(Throwable e)
private javax.ws.rs.core.Response.StatusType fromStatusCode(int statusCode)
private void transferResponse(javax.ws.rs.core.Response response, javax.servlet.http.HttpServletResponse servletResponse) throws IOException
IOException
Copyright © 2018. All Rights Reserved.