Subj : Re: Unable to access method of class To : visitus 04 From : Igor Bukanov Date : Wed Dec 15 2004 09:23 am visitus 04 wrote: > I am using Rhino to access methods and objects of java classes. I am > trying to access a method of class as follows: > > function test1(p1, p2, p3){ > e = new xyzException(); > try{ > printStr("Calling API "); > abcUtil.abcImport(p1, p2, p3); > } catch (e) { > printStr("RESULT=FAILURE"); > printStr(e.toString()); > printStr(e.getMessage()); <--- this line throws error > shown below > } > > } > However, I get an error > js: "C:\rhino\impExp.js", line 116: > uncaught JavaScript exception: TypeError: undefined is not a function. > (C:\rhino\impExp.js; line 116) Rhino exports to scripts the Java exception as "javaException" property of the exception object, so you example can be written as: } catch (e) { printStr("RESULT=FAILURE"); printStr(e.toString()); printStr(e.javaException.getMessage()); e.javaException.printStackTrace(); } In this way scripts can access "name", "message", "fileName" and "lineNumber" properties of the object e in the same way as they would access them for the standard EcmaScript exceptions. Regards, Igor .