private void prepareErrorDetails(final Throwable exception, final RequestContext requestContext,
final String errorRef, final String servletPath) {
final DebugString debugText = new DebugString();
final DebugHtmlString debugHtml = new DebugHtmlString();
final DebugBuilder debug = new DebugTee(debugText, debugHtml);
try {
debug.startSection("Exception");
debug.appendException(exception);
debug.endSection();
} catch (final RuntimeException e) {
debug.appendln("NOTE - an exception occurred while dumping an exception!");
debug.appendException(e);
}
if (IsisContext.getCurrentTransaction() != null) {
final List<String> messages = IsisContext.getMessageBroker().getMessages();
final List<String> warnings = IsisContext.getMessageBroker().getWarnings();
if (messages.size() > 0 || messages.size() > 0) {
debug.startSection("Warnings/Messages");
for (final String message : messages) {
debug.appendln("message", message);
}
for (final String message : warnings) {
debug.appendln("warning", message);
}
}
}
requestContext.append(debug);
debug.startSection("Processing Trace");
debug.appendPreformatted(requestContext.getDebugTrace());
debug.endSection();
debug.close();
PrintWriter writer;
try {
final String directory =
IsisContext.getConfiguration().getString(ConfigurationConstants.ROOT + "scimpi.error-snapshots", ".");