}
response.getHeaders().set(HttpHeaders.Names.CONTENT_TYPE, "text/html");
ByteBuf buffer = response.getChannel().alloc().buffer(1024);// 1KB initial length.
PrintStream printStream = null;
try {
printStream = new PrintStream(new ByteBufOutputStream(buffer));
error.printStackTrace(printStream);
String errorPage = ERROR_HTML_TEMPLATE.replace(STACKTRACE_TEMPLATE_VARIABLE,
buffer.toString(Charset.defaultCharset()));
response.writeString(errorPage);
} finally {