@Override public Response toResponse(ApplicationException e) { logException(e); Response.ResponseBuilder responseBuilder = Response.status(e.getHttpStatusCode()); if(e.getHttpStatusCode() == 500) { Monitors.error("error", "error"); } Map<String, Object> entityMap = e.toMap(); entityMap.put("instance", host); responseBuilder.type(MediaType.APPLICATION_JSON_TYPE); responseBuilder.entity(entityMap); return responseBuilder.build(); }
@Override public Response toResponse(Throwable exception) { LOGGER.error(String.format("Error %s url: '%s'", exception.getClass().getSimpleName(), uriInfo.getPath()), exception); Monitors.error("error", "error"); ApplicationException applicationException = null; if (exception instanceof IllegalArgumentException || exception instanceof InvalidFormatException) { applicationException = new ApplicationException(Code.INVALID_INPUT, exception.getMessage(), exception); } else { applicationException = new ApplicationException(Code.INTERNAL_ERROR, exception.getMessage(), exception); } Map<String, Object> entityMap = applicationException.toMap(); entityMap.put("instance", host); return Response.status(applicationException.getHttpStatusCode()).entity(entityMap).type(MediaType.APPLICATION_JSON_TYPE).build(); }
@Override public Response toResponse(ApplicationException e) { logException(e); Response.ResponseBuilder responseBuilder = Response.status(e.getHttpStatusCode()); if(e.getHttpStatusCode() == 500) { Monitors.error("error", "error"); } Map<String, Object> entityMap = e.toMap(); entityMap.put("instance", host); responseBuilder.type(MediaType.APPLICATION_JSON_TYPE); responseBuilder.entity(entityMap); return responseBuilder.build(); }
@Override public Response toResponse(Throwable exception) { LOGGER.error(String.format("Error %s url: '%s'", exception.getClass().getSimpleName(), uriInfo.getPath()), exception); Monitors.error("error", "error"); ApplicationException applicationException = null; if (exception instanceof IllegalArgumentException || exception instanceof InvalidFormatException) { applicationException = new ApplicationException(Code.INVALID_INPUT, exception.getMessage(), exception); } else { applicationException = new ApplicationException(Code.INTERNAL_ERROR, exception.getMessage(), exception); } Map<String, Object> entityMap = applicationException.toMap(); entityMap.put("instance", host); return Response.status(applicationException.getHttpStatusCode()).entity(entityMap).type(MediaType.APPLICATION_JSON_TYPE).build(); }