public Response toEntity() {
    HashMap<String, Object> respJson = new HashMap<>();
    respJson.put("trace", getCause());
    respJson.put("message", getMessage());
    respJson.put("status", Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
    return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
      .entity(respJson).type(MediaType.APPLICATION_JSON).build();
  }
Exception during work with Ambari API
contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApiException.java