On Jul 25, 2008, at 11:46 PM, Ivan Voras wrote:

> Hi,
>
> Several questions about error handling:
>
> What is the recommended way to report errors from host (Java) code
> called from JS code? What exceptions could (and should) the Java code
> throw?

It can throw just about any.  Don't worry about it -- you don't need  
to assume in your Java code that the caller is JS. Just write your  
Java code as you would if its callers were in Java. One minor caveat  
though below...

>
>
> How to get a stack trace of JS code when an error (or a Java exception
> like the above) happens, to show developers?

Just try it -- you will see that Rhino actually prints JS locations in  
the stack trace. Except (and here's your minor caveat) for non-checked  
exceptions. Rhino wraps checked exceptions in an instance of  
WrappedException, which is a subclass of RhinoException.  
RhinoException prints the JS locations in the stack trace. However,  
RuntimeException and Error are not wrapped, hence if these are thrown,  
you won't see a JS stack trace...

Attila.

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to