in pytheas-core/src/main/java/com/netflix/explorers/providers/WebApplicationExceptionMapper.java [49:88]
public Response toResponse(WebApplicationException error) {
if (error.getResponse() != null && (error.getResponse().getStatus() / 100) == 3) {
LOG.warn("Code: " + error.getResponse().getStatus());
return error.getResponse();
}
MediaType mediaType = context.getRequest().selectVariant(supportedMediaTypes).getMediaType();
if (mediaType != null && MediaType.APPLICATION_JSON_TYPE == mediaType) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
error.printStackTrace(ps);
return Response
.status(error.getResponse().getStatus())
.type(MediaType.APPLICATION_JSON_TYPE)
.entity(new JSONObject()
.put("code", error.getResponse().getStatus())
.put("url", context.getUriInfo().getPath())
.put("error", error.toString())
.put("message", error.getMessage())
.put("trace", baos.toString())
)
.build();
}
catch (JSONException e) {
// TODO:
}
}
// do not log 404
if (! is404(error)) {
LOG.warn(String.format("WebApplicationExceptionMapper status='%s' message='%s' url='%s'",
error.getResponse().getStatus(), error.getMessage(), context.getRequest().getPath()),
error);
}
return Response.status(error.getResponse().getStatus()).build();
}