protected static Response errorEntity(String message, Throwable e) {
    HashMap<String, Object> response = new HashMap<String, Object>();
    response.put("message", message);
    String trace = null;
    if (e != null)
      trace = ExceptionUtils.getStackTrace(e);
    response.put("trace", trace);
    response.put("status", STATUS);
    return Response.status(STATUS).entity(new JSONObject(response)).type(MediaType.APPLICATION_JSON).build();
  }
General server error that provides verbose response
to client with stack trace
contrib/views/capacity-scheduler/src/main/java/org/apache/ambari/view/capacityscheduler/utils/ServiceFormattedException.java