Bug 47509 - Exception in scriptdef prints entire stack trace
Summary: Exception in scriptdef prints entire stack trace
Status: RESOLVED WONTFIX
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: 1.7.1
Hardware: PC Windows 98
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-10 16:44 UTC by SlugFiller
Modified: 2009-07-13 04:00 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description SlugFiller 2009-07-10 16:44:47 UTC
When I run a scriptdef like:
	<scriptdef name="quickfail" language="beanshell">
		<![CDATA[
			self.fail("I failed!");
		]]>
	</scriptdef>

I expect to get an output like:

BUILD FAILED
C:\myproject\build.xml:10: [quickfail] I failed!

Or something of the sort... Instead I get:

BUILD FAILED
javax.script.ScriptException: Sourced file: inline evaluation of: ``self.fail("I failed!");                         ;'' : Method Invocation self.fail : at Line: 3 : in file: inline evaluation of: ``
self.fail("I failed!");
'' : self .fail ( "I failed!" );

Target exception: I failed!
in inline evaluation of: ``                                        self.fail("I failed!");
	at line number 3 '';
	at bsh.engine.BshScriptEngine.evalSource(BshScriptEngine.java:86)
	at bsh.engine.BshScriptEngine.eval(BshScriptEngine.java:46)
	at javax.script.AbstractScriptEngine.eval(Unknown Source)
.BshScriptEngine.evalSource(BshScriptEngine.java:86)
        at bsh.engine.BshScriptEngine.eval(BshScriptEngine.java:46)
        at javax.script.AbstractScriptEngine.eval(Unknown Source)
[...it keeps going for 3 more pages, making the original error very hard to read...]

I'm willing to grudgingly accept such an output for an IOException, or even a syntax error, but for a user-generated fail? What's the point of providing a custom fail command if it looks like a full system crash?

I haven't checked if this is beanshell specific, or if it applies to javascript and other languages as well, since I only have beanshell installed.
Comment 1 Stefan Bodewig 2009-07-13 04:00:49 UTC
I haven't tried beanshell but JavaScript in svn revision 793540

When using Apache BSF things are just like one would want them to be - a one line "I failed!" message.

But using javax.script things look ugly.  Unfortunately the scripting engine throws a ScriptException without any nested cause in this case, completely hiding the original BuildException.

The beanshell implementation may be doing better, in which case the changes committed in above revision may help.

If it doesn't, then I'm afraid there isn't anything we can do from Ant's side.

Using WONTFIX as a placeholder for CANTFIX.