Hi Jason,

I tried out your proposal like below:

            try {
                if(name != null) {
                    this.wForm.lookupWidget("name").setValue(name)
                    this.version = CustomizableClassBinding.save(name,
this.wForm, this.version);
                }
            } catch (ex) {
                print(ex.getWrappedException());
            }

It now gives me following error:
Message: TypeError: Cannot find function getWrappedException.
(file:/C:/osrdev/xenopsis/build/webapp/./xenopsis/content/portal/model/class
form.js#111)

Cheers,
Robby

-----Oorspronkelijk bericht-----
Van: Jason Johnston [mailto:[EMAIL PROTECTED] 
Verzonden: woensdag 10 januari 2007 4:17
Aan: [email protected]
Onderwerp: Re: how to catch and throw exceptions in cocoon2.1.10
(javascript)

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to