code: public JSONObject handleThrowable(Throwable pThrowable) {
          if (pThrowable instanceof IllegalArgumentException) {
              return getErrorJSON(400,pThrowable, null);
          } else if (pThrowable instanceof SecurityException) {
              // Wipe out stacktrace
              return getErrorJSON(403,new Exception(pThrowable.getMessage()), null);
          } else {
              return getErrorJSON(500,pThrowable, null);
          }
      }
docs: Utility method for handling single runtime exceptions and errors. This method is called
  in addition to and after {@link #executeRequest(JmxRequest)} to catch additional errors.
  They are two different methods because of bulk requests, where each individual request can
  lead to an error. So, each individual request is wrapped with the error handling of
  {@link #executeRequest(JmxRequest)}
  whereas the overall handling is wrapped with this method. It is hence more coarse grained,
  leading typically to an status code of 500.
  
  Summary: This method should be used as last security belt is some exception should escape
  from a single request processing in {@link #executeRequest(JmxRequest)}.
  
  @param pThrowable exception to handle
  @return its JSON representation