From 83636d2c09802aeeb1b30078022d228d04da21eb Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 15 Aug 2014 16:17:25 +0200 Subject: java: when rethrowing exceptions, store the original cause so that we get a nice complete stacktrace when it hits the final handler Change-Id: Iec4fcc15a2a25c55f591b5e069dce3d010197a90 --- .../java/org/openoffice/xmerge/converter/dom/DOMDocument.java | 11 ++++------- .../org/openoffice/xmerge/converter/xml/OfficeDocument.java | 7 ++----- 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'xmerge') diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java index a2e67c08f4cf..cbade8a53ffc 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java @@ -27,7 +27,6 @@ import java.io.IOException; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; - import javax.xml.transform.TransformerFactory; import javax.xml.transform.Transformer; import javax.xml.transform.stream.StreamResult; @@ -36,7 +35,6 @@ import javax.xml.transform.dom.DOMSource; import org.w3c.dom.Node; import org.w3c.dom.Document; import org.xml.sax.SAXException; - import org.openoffice.xmerge.util.Debug; /** @@ -296,16 +294,15 @@ public class DOMDocument throw new IOException("No appropriate API (JAXP/Xerces) to serialize XML document: " + domImpl); } } - } catch (ClassNotFoundException cnfe) { - throw new IOException(cnfe.toString()); - } catch (Exception e) { + } + catch (Exception e) { // We may get some other errors, but the bottom line is that // the steps being executed no longer work - throw new IOException(e.toString()); + throw new IOException(e); } byte bytes[] = baos.toByteArray(); return bytes; } -} \ No newline at end of file +} diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java index df3fec9660b1..d468b426ac45 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java @@ -813,17 +813,14 @@ public abstract class OfficeDocument return writer.toString().getBytes(); } catch (Exception e) { // We don't have another parser - throw new IOException("No appropriate API (JAXP/Xerces) to serialize XML document: " + domImpl); + throw new IOException("No appropriate API (JAXP/Xerces) to serialize XML document: " + domImpl, e); } } } - catch (ClassNotFoundException cnfe) { - throw new IOException(cnfe.toString()); - } catch (Exception e) { // We may get some other errors, but the bottom line is that // the steps being executed no longer work - throw new IOException(e.toString()); + throw new IOException(e); } byte bytes[] = baos.toByteArray(); -- cgit v1.2.3