Subj : Re: Rhino: Accessing embedded exception in JavaException To : netscape.public.mozilla.jseng From : lgardner Date : Tue Apr 20 2004 11:12 pm Igor, thanks for your reply; I should have included that I'm already using Rhino 1.5R5. Unfortunately your solution does not seem to work for me. This is the output: try { callJavaFunctionThrowingFooException(); } catch (ex) { print(ex); // prints: JavaException: FooException: print(ex.getWrappedException()); // undefined error } If I analyse the exception class further it seems to be of the type org.mozilla.javascript.NativeError. Where am I going wrong? BTW, FooException is a RuntimeException, could that be the reason? If yes, is there any way I can still get at the original exception? thanks, Lewis Igor Bukanov wrote in message news:<4084EEC6.6000206@fastmail.fm>... > Lewis Gardner wrote: > > Hi, > > when I call a Java method via LiveConnect (Rhino) and the method > > throws an exception the type of the exception thrown in > > "JavaException". Is there any way I can access the original exception, > > the one actually thrown by the Java method? > > I would suggest to upgrade to Rhino 1.5R5 which consistently rethrows > exceptions from Java methods as org.mozilla.javascript.WrappedException > where the method getWrappedException() returns the original exception > object. > > Prior 1.5R5 Rhino could throw either > org.mozilla.javascript.WrappedException or > org.mozilla.javascript.JavaScriptException and in the later case to get > the original object you have to call getValue() method there, check if > it is an instance of Throwable and in addition if that was an instance > of WrappedException, then call getWrappedException() to get the real > exception source. > > In Rhino 1.5R5 JavaScriptException represents only exceptions thrown by > scripts with JavaScript "throw" statement. > > Regards, Igor .