throw new RuntimeException("Failed to generate exception document.", e);
}
}
private void toSAX(Throwable throwable, ContentHandler handler) throws SAXException {
AttributesImpl attr = new AttributesImpl();
// handler.startPrefixMapping("ex", EXCEPTION_NS);
attr.addCDATAAttribute("class", throwable.getClass().getName());
attr.addCDATAAttribute("timestamp", this.dateFormat.format(new Date()));
handler.startElement(EXCEPTION_NS, "exception-report", "exception-report", attr);
// handler.startElement(EXCEPTION_NS, "exception-report", "ex:exception-report", attr);
// exception message
attr.clear();
simpleElement("message", attr, throwable.getMessage(), handler);
// exception stacktrace
attr.clear();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
throwable.printStackTrace(pw);
simpleElement("stacktrace", attr, sw.getBuffer().toString(), handler);