Re: source command enhancement

Patrick Niemeyer <[email protected]> Wed, 6 Jul 2005 22:58:21 -0500
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
On Jul 6, 2005, at 5:40 AM, Michael Pitoniak wrote:

>  it would be nice if the source() command checked for syntax errors  
> in the sourced script prior to executing it, as if this is the case  
> the Interpreter exits, and the calling  script cannot recover.
> i have enhanced the source() command to do this, as several of our  
> scripts source others, and if they are sloppy it terminates the  
> calling script.

You should be able to simply surround the source() command with a try/ 
catch block to catch any parse exceptions:

try {
   source("foo.bsh");
catch( e ) { print(e); }


Pat