Subj : Re: Unable to access method of class To : visitus 04 From : Igor Bukanov Date : Wed Dec 15 2004 11:34 pm visitus 04 wrote: > Igor, > > Thanks for your response. I was able to use getMessage() method. > > I am having a similar problem with another class that is being exported > into Rhino. How can I find out as to what the class gets exported as? > In previous example, you said that exception gets exported as > javaException. Is there any way to find that out? The case of exceptions is special since one to allow for better fit of exceptions generated in Java code with JS exceptions that ECMAScript require to generate. There are no other special classes. Regards, Igor > > Thanks > > > */Igor Bukanov /* wrote: > > 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 > _______________________________________________ > mozilla-jseng mailing list > mozilla-jseng@mozilla.org > http://mail.mozilla.org/listinfo/mozilla-jseng > > ------------------------------------------------------------------------ > Do you Yahoo!? > Yahoo! Mail - 250MB free storage. Do more. Manage less. > .