Hi Gregg,
If you don't want to have many types mappers and exception, you could have a
generic service exception like:
@Provider
public class ServiceExceptionMapper implements
ExceptionMapper<ServiceException> {
public Response toResponse(ServiceException ex) {
return
Response.status(ex.getResponseStatusCode()).entity(ex.getFaultInfo()).build();
}
}
I do have exceptions and mappers for type of exception I want to address.
That was part of my application requirement as well. For all other types of
exceptions I use a generic exception type:
FaultInfo fault = new FaultInfo();
fault.setErrorCode(ServiceErrorCode.INTERNAL_SERVER_ERROR);
fault.setReason(ex.getMessage());
fault.setResource(uriInfo.getPath());
fault.setException(StackTraceUtil.getStackTraceAsString(ex));
GenericServiceException ge = new GenericServiceException(fault);
ge.initCause(ex.getCause());
throw ge;
Hope this helps.
Thanks,
Mathew
--
View this message in context: http://jersey.576304.n2.nabble.com/ExceptionMapper-not-handling-Exception-subclasses-tp5235614p5235927.html
Sent from the Jersey mailing list archive at Nabble.com.