/** * Returns the specified exception as XML. * * @param ex The exception to turn to XML. * @param xml The XML writer. * @param wrap Whether to wrap the XML into an element. * * @throws IOException Only if thrown by the XML writer. */ public static void toXML(Throwable ex, XMLWriter xml, boolean wrap) throws IOException { if (ex instanceof SAXParseException) { asSAXParseExceptionXML((SAXParseException)ex, xml, wrap); } else if (ex instanceof TransformerException) { asTransformerExceptionXML((TransformerException)ex, xml, wrap); } else if (ex instanceof Exception) { asExceptionXML((Exception)ex, xml, wrap); } else if (ex instanceof Error) { asErrorXML((Error)ex, xml, wrap); } }