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