aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2009-09-26 20:38:23 +0000
committerJeremias Maerki <jeremias@apache.org>2009-09-26 20:38:23 +0000
commit2d26284592d2d7e31e1c28e94d230d6166f8ef3e (patch)
treee5597120c29904a0faa6828ea0e4fe2b95069360
parentb4df075d6d5ead685c6fd56a42880b3f73d8a3b8 (diff)
downloadxmlgraphics-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.java16
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);
+ }
}
}