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
This commit is contained in:
Jeremias Maerki 2009-09-26 20:38:23 +00:00
parent b4df075d6d
commit 2d26284592

View File

@ -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);
}
}
}