code: void sendError(HttpResponseStatus status, Throwable ex) {
      String msg;
  
      if (ex instanceof InvocationTargetException) {
        msg = String.format("Exception Encountered while processing request : %s", ex.getCause().getMessage());
      } else {
        msg = String.format("Exception Encountered while processing request: %s", ex.getMessage());
      }
  
      // Send the status and message, followed by closing of the connection.
      responder.sendString(status, msg, new DefaultHttpHeaders().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE));
      if (bodyConsumer != null) {
        bodyConsumerError(ex);
      }
    }
docs: Sends the error to responder.