code: public static void writeErrorResponse(MessageEvent messageEvent,
                                            HttpResponseStatus status,
                                            String message) {
  
          // Create the Response object
          HttpResponse response = new DefaultHttpResponse(HTTP_1_1, status);
          response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8");
          response.setContent(ChannelBuffers.copiedBuffer("Failure: " + status.toString() + ". "
                                                          + message + "\r\n", CharsetUtil.UTF_8));
          response.setHeader(CONTENT_LENGTH, response.getContent().readableBytes());
  
          // Write the response to the Netty Channel
          messageEvent.getChannel().write(response);
      }
docs: Writes all error responses to the client.
  
  TODO REST-Server 1. collect error stats
  
  @param messageEvent - for retrieving the channel details
  @param status - error code
  @param message - error message