FYI
-----Oorspronkelijk bericht-----
Van: Robby Pelssers, AGP [mailto:[EMAIL PROTECTED]
Verzonden: woensdag 10 januari 2007 10:39
Aan: 'Bruno Dumon'
Onderwerp: RE: how to catch and throw exceptions in cocoon2.1.10
(javascript)
Thanx Bruno,
Now the code below
try {
if(name != null) {
this.wForm.lookupWidget("name").setValue(name)
this.version = CustomizableClassBinding.save(name,
this.wForm, this.version);
}
} catch(ex if ex.javaException instanceof
StoreItemDeletedException) {
print("Finaly the right catchblock is executed !!");
} catch (ex) {
print("the exception = " + ex.javaException);
}
Falls back to the right catch block and I see "Finaly the right catchblock
is executed !!" in my console :-)
Is this documented somewhere since I checked the javascript reference and
guide but using javaException did not catch my eye...
Cheers,
Robby
-----Oorspronkelijk bericht-----
Van: Bruno Dumon [mailto:[EMAIL PROTECTED] Namens Bruno Dumon
Verzonden: woensdag 10 januari 2007 10:27
Aan: [EMAIL PROTECTED]
Onderwerp: RE: how to catch and throw exceptions in cocoon2.1.10
(javascript)
Robby,
seems my original reply to the users list sits in some moderation queue, but
you could try:
ex.javaException instanceof ...
On Wed, 2007-01-10 at 10:20 +0100, Robby Pelssers, AGP wrote:
> 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/WrappedExc
> eption
> .html
>
> --Jason
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
[EMAIL PROTECTED] [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]