throw new IOException("A writer is already opened for streaming or the response was already sent.");
}
try {
ChannelBuffer errorContent = ChannelBuffers.wrappedBuffer(Charsets.UTF_8.encode(errorMessage));
HttpResponse httpResponse = createHttpResponse(new ProcedureResponse(errorCode));
httpResponse.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/plain");
httpResponse.setHeader(HttpHeaders.Names.CONTENT_LENGTH, errorContent.readableBytes());
httpResponse.setContent(errorContent);
channel.write(httpResponse).addListener(ChannelFutureListener.CLOSE);
} finally {