final File dir = new File(directory);
if (!dir.exists()) {
dir.mkdirs();
}
writer = new PrintWriter(new File(dir, "error_" + errorRef + ".html"));
final DebugWriter writer2 = new DebugWriter(writer, true);
writer2.concat(debugHtml);
writer2.close();
writer.close();
} catch (final FileNotFoundException e) {
LOG.error("Failed to archive error page", e);
}