diff --git a/WHATSNEW b/WHATSNEW index 6058a3daa..49e21d8b9 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -46,6 +46,9 @@ Changes that could break older environments: didn't depend on Xalan-J 2 at all. Its sole dependency has always been TraX and so it has been merged into ant-trax.jar. +* All exceptions thrown by tasks are now wrapped in a buildexception + giving the location in the buildfile of the task. + Fixed bugs: ----------- diff --git a/src/main/org/apache/tools/ant/Task.java b/src/main/org/apache/tools/ant/Task.java index 998fa6909..92c455cd5 100644 --- a/src/main/org/apache/tools/ant/Task.java +++ b/src/main/org/apache/tools/ant/Task.java @@ -362,15 +362,19 @@ public abstract class Task extends ProjectComponent { try { maybeConfigure(); execute(); - } catch (RuntimeException exc) { - if (exc instanceof BuildException) { - BuildException be = (BuildException) exc; - if (be.getLocation() == Location.UNKNOWN_LOCATION) { - be.setLocation(getLocation()); - } + } catch (BuildException ex) { + if (ex.getLocation() == Location.UNKNOWN_LOCATION) { + ex.setLocation(getLocation()); } - reason = exc; - throw exc; + reason = ex; + } catch (Exception ex) { + reason = ex; + BuildException be = new BuildException(ex); + be.setLocation(getLocation()); + throw be; + } catch (Error ex) { + reason = ex; + throw ex; } finally { getProject().fireTaskFinished(this, reason); }