docs: public ChannelBuffer formatErrorV1(final Exception exception) {
      String message = exception.getMessage();
      // NPEs have a null for the message string (why?!?!?!)
      if (exception.getClass() == NullPointerException.class) {
        message = "An internal null pointer exception was thrown";
      } else if (message == null) {
        message = "An unknown exception occurred";
      }
      StringBuilder output = 
        new StringBuilder(message.length() * 2);
      final String jsonp = query.getQueryStringParam("jsonp");
      if (jsonp != null && !jsonp.isEmpty()) {
        output.append(query.getQueryStringParam("jsonp") + "(");
      }
      output.append("{\"error\":{\"code\":");
      output.append(500);
      final StringBuilder msg = new StringBuilder(message.length());
      HttpQuery.escapeJson(message, msg);
      output.append(",\"message\":\"").append(msg.toString()).append("\"");
      if (query.showStackTrace()) {
        ThrowableProxy tp = new ThrowableProxy(exception);
        tp.calculatePackagingData();
        final String pretty_exc = ThrowableProxyUtil.asString(tp);
        final StringBuilder trace = new StringBuilder(pretty_exc.length());
        HttpQuery.escapeJson(pretty_exc, trace);
        output.append(",\"trace\":\"").append(trace.toString()).append("\"");
      }
      output.append("}}");
      if (jsonp != null && !jsonp.isEmpty()) {
        output.append(")");
      }
      return ChannelBuffers.copiedBuffer(
          output.toString().getBytes(this.query.getCharset()));
    }