code: public static CompletableFuture<Void> sendErrorResponse(
  			ChannelHandlerContext channelHandlerContext,
  			boolean keepAlive,
  			ErrorResponseBody errorMessage,
  			HttpResponseStatus statusCode,
  			Map<String, String> headers) {
  
  		StringWriter sw = new StringWriter();
  		try {
  			mapper.writeValue(sw, errorMessage);
  		} catch (IOException e) {
  			// this should never happen
  			LOG.error("Internal server error. Could not map error response to JSON.", e);
  			return sendResponse(
  				channelHandlerContext,
  				keepAlive,
  				"Internal server error. Could not map error response to JSON.",
  				HttpResponseStatus.INTERNAL_SERVER_ERROR,
  				headers);
  		}
  		return sendResponse(
  			channelHandlerContext,
  			keepAlive,
  			sw.toString(),
  			statusCode,
  			headers);
  	}
docs: Sends the given error response and status code to the given channel.
  
  @param channelHandlerContext identifying the open channel
  @param keepAlive If the connection should be kept alive.
  @param errorMessage which should be sent
  @param statusCode of the message to send
  @param headers additional header values