You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Martin Rusnak <ma...@cyberspace.sk> on 2004/11/01 15:28:16 UTC

Exception handling in flow script

Hello all,
Is it possible to catch and handle a specific exception class in flow script, like it
is in Java? For example:

try {
	registrator.register()
} catch (RegistrationException e) {
	// do something
}

Martin

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


Re: Exception handling in flow script

Posted by Brent Johnson <bl...@gmail.com>.
Someone can correct me if I'm wrong.  But I dont think you can use the
Java syntax for catching typed Exceptions in Javascript.  I think you
have to test the exception type in the catch with an if-statement
instead.

- Brent

On Mon, 1 Nov 2004 15:19:31 +0000, beyaNet <an...@jibeya.com> wrote:
> Martin,
> again yes. Specify the class you wish to catch as you have done:
> 
> 
> 
> >>> } catch (RegistrationException e) {
> >>>     // do something
> >>> }
> 
> Andrew
> On 1 Nov 2004, at 15:09, Martin Rusnak wrote:
> 
> > But in this example all exceptions are caught. Instead I want to catch
> > and handle
> > only exception of specific class and I want all other exceptions to be
> > handled
> > by the default handler.
> >
> > beyaNet wrote:
> >> Martin,
> >> in a word, YES!
> >> importClass(Packages.test.Artist);
> >> var artist;
> >> var error_msg;
> >> function artistDetails() {
> >>         try {
> >>         artist = Artist.getArtist(cocoon.request.artID);
> >>            }catch(e) {
> >>         error_msg = e.toString();
> >>     }
> >> hope that helps ;-)
> >> Andrew
> >> On 1 Nov 2004, at 14:28, Martin Rusnak wrote:
> >>> Hello all,
> >>> Is it possible to catch and handle a specific exception class in
> >>> flow script, like it
> >>> is in Java? For example:
> >>>
> >>> try {
> >>>     registrator.register()
> >>> } catch (RegistrationException e) {
> >>>     // do something
> >>> }
> >>>
> >>> Martin
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >>> For additional commands, e-mail: users-help@cocoon.apache.org
> >>>
> >>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >> For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
> 
> 
> 
>  +The home of urban music
>   + http://www.beyarecords.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
>

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


Re: Exception handling in flow script

Posted by beyaNet <an...@jibeya.com>.
Martin,
again yes. Specify the class you wish to catch as you have done:

>>> } catch (RegistrationException e) {
>>>     // do something
>>> }

Andrew
On 1 Nov 2004, at 15:09, Martin Rusnak wrote:

> But in this example all exceptions are caught. Instead I want to catch 
> and handle
> only exception of specific class and I want all other exceptions to be 
> handled
> by the default handler.
>
> beyaNet wrote:
>> Martin,
>> in a word, YES!
>> importClass(Packages.test.Artist);
>> var artist;
>> var error_msg;
>> function artistDetails() {
>>         try {
>>         artist = Artist.getArtist(cocoon.request.artID);
>>            }catch(e) {
>>         error_msg = e.toString();
>>     }
>> hope that helps ;-)
>> Andrew
>> On 1 Nov 2004, at 14:28, Martin Rusnak wrote:
>>> Hello all,
>>> Is it possible to catch and handle a specific exception class in 
>>> flow script, like it
>>> is in Java? For example:
>>>
>>> try {
>>>     registrator.register()
>>> } catch (RegistrationException e) {
>>>     // do something
>>> }
>>>
>>> Martin
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Re: Exception handling in flow script

Posted by Brent Johnson <bl...@gmail.com>.
I think you can do something like this (although I've never tried it):

try {
    artist = Artist.getArtist(cocoon.request.artID);
} catch(e) {

    if (e instanceof TypeError) {
        // do something
    } else {
        // do something for all other exceptions
    }

}

Hope this helps.

- Brent

On Mon, 01 Nov 2004 16:09:09 +0100, Martin Rusnak <ma...@cyberspace.sk> wrote:
> But in this example all exceptions are caught. Instead I want to catch and handle
> only exception of specific class and I want all other exceptions to be handled
> by the default handler.
> 
> 
> 
> beyaNet wrote:
> > Martin,
> > in a word, YES!
> >
> > importClass(Packages.test.Artist);
> >
> > var artist;
> > var error_msg;
> >
> > function artistDetails() {
> >
> >     try {
> >         artist = Artist.getArtist(cocoon.request.artID);
> >
> >     }catch(e) {
> >         error_msg = e.toString();
> >     }
> >
> > hope that helps ;-)
> >
> >
> > Andrew
> >
> > On 1 Nov 2004, at 14:28, Martin Rusnak wrote:
> >
> >> Hello all,
> >> Is it possible to catch and handle a specific exception class in flow
> >> script, like it
> >> is in Java? For example:
> >>
> >> try {
> >>     registrator.register()
> >> } catch (RegistrationException e) {
> >>     // do something
> >> }
> >>
> >> Martin
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >> For additional commands, e-mail: users-help@cocoon.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
>

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


Re: Exception handling in flow script

Posted by Steven Gong <st...@gmail.com>.
On Mon, 01 Nov 2004 16:09:09 +0100, Martin Rusnak <ma...@cyberspace.sk> wrote:
> But in this example all exceptions are caught. Instead I want to catch and handle
> only exception of specific class and I want all other exceptions to be handled
> by the default handler.
IMHO, if you need to catch the exact type of exception and try to do
something you should do it in business methods other than in js. In
js, the exception is used to send some pages to notify client
something was wrong and the exact type can be filtered by exception
handler in sitemap.

Regards,
Steven Gong

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


Re: Exception handling in flow script

Posted by Martin Rusnak <ma...@cyberspace.sk>.
But in this example all exceptions are caught. Instead I want to catch and handle
only exception of specific class and I want all other exceptions to be handled
by the default handler.

beyaNet wrote:
> Martin,
> in a word, YES!
> 
> importClass(Packages.test.Artist);
> 
> var artist;
> var error_msg;
> 
> function artistDetails() {
>     
>     try {
>         artist = Artist.getArtist(cocoon.request.artID);
>        
>     }catch(e) {
>         error_msg = e.toString();
>     }
> 
> hope that helps ;-)
> 
> 
> Andrew
> 
> On 1 Nov 2004, at 14:28, Martin Rusnak wrote:
> 
>> Hello all,
>> Is it possible to catch and handle a specific exception class in flow 
>> script, like it
>> is in Java? For example:
>>
>> try {
>>     registrator.register()
>> } catch (RegistrationException e) {
>>     // do something
>> }
>>
>> Martin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


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


Re: Exception handling in flow script

Posted by beyaNet <an...@jibeya.com>.
Martin,
in a word, YES!

importClass(Packages.test.Artist);

var artist;
var error_msg;

function artistDetails() {
	
	try {
		artist = Artist.getArtist(cocoon.request.artID);
		
	}catch(e) {
		error_msg = e.toString();
	}

hope that helps ;-)


Andrew

On 1 Nov 2004, at 14:28, Martin Rusnak wrote:

> Hello all,
> Is it possible to catch and handle a specific exception class in flow 
> script, like it
> is in Java? For example:
>
> try {
> 	registrator.register()
> } catch (RegistrationException e) {
> 	// do something
> }
>
> Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


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