diff options
author | Jeremias Maerki <jeremias@apache.org> | 2009-09-26 20:38:23 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2009-09-26 20:38:23 +0000 |
commit | 2d26284592d2d7e31e1c28e94d230d6166f8ef3e (patch) | |
tree | e5597120c29904a0faa6828ea0e4fe2b95069360 | |
parent | b4df075d6d5ead685c6fd56a42880b3f73d8a3b8 (diff) | |
download | xmlgraphics-fop-2d26284592d2d7e31e1c28e94d230d6166f8ef3e.tar.gz xmlgraphics-fop-2d26284592d2d7e31e1c28e94d230d6166f8ef3e.zip |
Attach cause to RuntimeException when available. Otherwise, the original exception can be swallowed which makes error forensics more difficult.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@819205 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/fop/events/EventExceptionManager.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/java/org/apache/fop/events/EventExceptionManager.java b/src/java/org/apache/fop/events/EventExceptionManager.java index f6a115450..1072600c9 100644 --- a/src/java/org/apache/fop/events/EventExceptionManager.java +++ b/src/java/org/apache/fop/events/EventExceptionManager.java @@ -58,7 +58,21 @@ public class EventExceptionManager { } } else { String msg = EventFormatter.format(event); - throw new RuntimeException(msg); + //Get original exception as cause if it is given as one of the parameters + Throwable t = null; + Iterator iter = event.getParams().values().iterator(); + while (iter.hasNext()) { + Object o = iter.next(); + if (o instanceof Throwable) { + t = (Throwable)o; + break; + } + } + if (t != null) { + throw new RuntimeException(msg, t); + } else { + throw new RuntimeException(msg); + } } } |