cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Johnston <coc...@lojjic.net>
Subject Re: how to catch and throw exceptions in cocoon2.1.10 (javascript)
Date Wed, 10 Jan 2007 03:16:33 GMT
Robby Pelssers, AGP wrote:
> Hi,
>  
> I'm facing a problem that my old javascript file no longer works 
> properly with constructions like instanceof, getClass(), throw.   Can 
> someone point me out how to do this?
>  
> try {
> } catch (ex) {
>     if (ex  instanceof Packages.xxxx.xxxx.xxxx) {
>         //Do something 1
>     } else if (ex.getClass().getName().equals("xxxx")) {
>         //Do something 2
>     }  else {
>         //Do something 3
>         throw(ex);
>     }
> }


If I recall, the new version of Rhino treats exceptions from the Java 
layer differently than it used to.  It used to pass them up to the JS 
catch statement directly, whereas now it wraps them in a 
org.mozilla.javascript.WrappedException.  You should be able to get 
access to your original Java exception by unwrapping it with 
ex.getWrappedException().

See 
http://www.mozilla.org/rhino/apidocs/org/mozilla/javascript/WrappedException.html

--Jason


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message