Bug 50749 - <script> should unwrap ScriptException when reporting errors to the user
Summary: <script> should unwrap ScriptException when reporting errors to the user
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.8.1
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-10 00:17 UTC by Trejkaz (pen name)
Modified: 2011-02-10 00:23 UTC (History)
0 users



Attachments
Sample build file (277 bytes, text/plain)
2011-02-10 00:21 UTC, Trejkaz (pen name)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Trejkaz (pen name) 2011-02-10 00:17:39 UTC
If I put in a <script> which calls some other task and that task fails for some reason, the reason gets obscured by being wrapped in a ScriptException.  As I was the one who wrote all the scripts in our builds, people immediately come to me, assuming that the script is at fault.

The result of running a task via a script should mirror the result of running it directly.  I suspect that this is just a matter of unwrapping the ScriptException to expose the real exception, but Ant is not printing the nested exception so it is not clear how much unwrapping would be needed.
Comment 1 Trejkaz (pen name) 2011-02-10 00:21:51 UTC
Created attachment 26631 [details]
Sample build file

Attaching a trivial sample build script causing an error.  The root cause message *is* included in the exception, but most users don't seem to scour it too well, and stop at "ScriptException".


------------ Result of running a task normally:
$ ant run-normally
Buildfile: /Users/daniel/Desktop/Test/Ant/build.xml

run-normally:

BUILD FAILED
/Users/daniel/Desktop/Test/Ant/build.xml:10: Classname must not be null.

Total time: 0 seconds


------------ Result of running the same task via a script:
$ ant run-using-script
Buildfile: /Users/daniel/Desktop/Test/Ant/build.xml

run-using-script:

BUILD FAILED
/Users/daniel/Desktop/Test/Ant/build.xml:3: javax.script.ScriptException: sun.org.mozilla.javascript.internal.WrappedException: Wrapped Classname must not be null. (<Unknown source>#3) in <Unknown source> at line number 3
	at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:110)
	at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:124)
	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.tools.ant.util.ReflectUtil.invoke(ReflectUtil.java:108)
	at org.apache.tools.ant.util.ReflectWrapper.invoke(ReflectWrapper.java:81)
	at org.apache.tools.ant.util.optional.JavaxScriptRunner.evaluateScript(JavaxScriptRunner.java:104)
	at org.apache.tools.ant.util.optional.JavaxScriptRunner.executeScript(JavaxScriptRunner.java:68)
	at org.apache.tools.ant.taskdefs.optional.Script.execute(Script.java:52)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.Target.execute(Target.java:390)
	at org.apache.tools.ant.Target.performTasks(Target.java:411)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1249)
	at org.apache.tools.ant.Main.runBuild(Main.java:801)
	at org.apache.tools.ant.Main.startAnt(Main.java:218)
	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 0 seconds
Comment 2 Trejkaz (pen name) 2011-02-10 00:23:34 UTC
Forgot to set the issue to enhancement.  Though the impact on myself is highly annoying since people are blaming me for their own screw-ups.