You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bsf-user@jakarta.apache.org by big d <da...@yahoo.com> on 2006/12/20 15:45:27 UTC

Any error reporting in BSF?

Hi,

I am prototyping some code to include JRuby scripts in a Java app for
extensibility, and found that BSF/JRuby is not reporting compile errors.  I
run a script (with a typo in "include_class") and all I get is this generic
exception:


Dec 20, 2006 9:39:17 AM scratch.test.TestJruby1 main
INFO: org.apache.bsf.BSFException: Exception
org.apache.bsf.BSFException: Exception
	at org.jruby.javasupport.bsf.JRubyEngine.exec(JRubyEngine.java:113)
	at org.apache.bsf.BSFManager$6.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.bsf.BSFManager.exec(Unknown Source)

Here's the code to produce this (concat is a function that builds a string
with newlines between each element):

	BSFManager.registerScriptingEngine("ruby",
"org.jruby.javasupport.bsf.JRubyEngine", new String[] { "rb" });

	String script = concat(
			new String[] { 
					"require 'java'",
					"include class 'java.util.HashSet'", // ERROR!!!
					"begin ",
					"  set=HashSet.new",
					"  set.add 'foo'",
					"  set.add 'bar'",
					"  set.add 'fubar'",
					"  print set", 
					"rescue StandardError => err ", 
					"  print \"Error:: \" + err ",
					"end ", 
			});
				
	BSFManager manager = new BSFManager();
	manager.exec("ruby", "(java)", 1, 1, script);

 shouldn't there be some indication of the compile error?  Running directlly
in JRuby produces this (syntax) error:

$  java -jar lib/jruby.jar c:/tmp/fooBarTest.rb
:[-1,-1]:[0,0]: c:/tmp/fooBarTest.rb:1: syntax error, expecting '['     tDOT   
tCOLON2 but found '\n' instead (SyntaxError)


-- 
View this message in context: http://www.nabble.com/Any-error-reporting-in-BSF--tf2860171.html#a7991246
Sent from the BSF - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-user-help@jakarta.apache.org


Re: Any error reporting in BSF?

Posted by "Rony G. Flatscher" <Ro...@wu-wien.ac.at>.
Hi Big d,

> I am prototyping some code to include JRuby scripts in a Java app for
> extensibility, and found that BSF/JRuby is not reporting compile errors.  I
> run a script (with a typo in "include_class") and all I get is this generic
> exception:
>
>
> Dec 20, 2006 9:39:17 AM scratch.test.TestJruby1 main
> INFO: org.apache.bsf.BSFException: Exception
> org.apache.bsf.BSFException: Exception
> 	at org.jruby.javasupport.bsf.JRubyEngine.exec(JRubyEngine.java:113)
> 	at org.apache.bsf.BSFManager$6.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at org.apache.bsf.BSFManager.exec(Unknown Source)
>
> Here's the code to produce this (concat is a function that builds a string
> with newlines between each element):
>
> 	BSFManager.registerScriptingEngine("ruby",
> "org.jruby.javasupport.bsf.JRubyEngine", new String[] { "rb" });
>
> 	String script = concat(
> 			new String[] { 
> 					"require 'java'",
> 					"include class 'java.util.HashSet'", // ERROR!!!
> 					"begin ",
> 					"  set=HashSet.new",
> 					"  set.add 'foo'",
> 					"  set.add 'bar'",
> 					"  set.add 'fubar'",
> 					"  print set", 
> 					"rescue StandardError => err ", 
> 					"  print \"Error:: \" + err ",
> 					"end ", 
> 			});
> 				
> 	BSFManager manager = new BSFManager();
> 	manager.exec("ruby", "(java)", 1, 1, script);
>
>  shouldn't there be some indication of the compile error?  Running directlly
> in JRuby produces this (syntax) error:
>   
At one point in time an explicit debugging subsystem was experimentally
created for BSF, but got later removed. (Each language has usually its
own means of debugging.)

What you get is the exception info originating from the  JRubyEngine. So
in your particular case that would be the place to add code which would
give you more (JRuby-related) information about the exception condition
(in your case that a syntax error was found by JRuby).

HTH a little bit,

---rony



---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-user-help@jakarta.apache.org