jakarta-bsf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rony G. Flatscher" <Rony.Flatsc...@wu-wien.ac.at>
Subject Re: Any error reporting in BSF?
Date Thu, 28 Dec 2006 16:42:22 GMT
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


Mime
View raw message