private Response mapNormal(UUID id, Exception exception, String when) { if (exception instanceof PortalException && exception.getCause() != null) { final PortalException pe = (PortalException) exception; final Response r = pe.getResponse(); Loggers.core().error(String.format("Port@l Exception [%s] during %s processing", id, when), exception); final ResponseBuilder b = Response.fromResponse(r); b.entity(String.format("Port@l Exception [%s]: %s", id, r.getEntity())); return b.build(); } if (exception instanceof WebApplicationException) { return ((WebApplicationException) exception).getResponse(); } Loggers.core().error(String.format("Exception [%s] during %s processing", id, when), exception); return Response.serverError().type(MediaType.TEXT_PLAIN_TYPE) .entity(String.format("Exception [%s]. See error log for details", id)).build(); } }