You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Timothy Larson <ti...@yahoo.com> on 2003/09/09 21:55:56 UTC

Flow and map:handle-errors

If I request a page where the pipeline encounters an error
(e.g. file not found) then the handle-errors pipeline is
invoked. However, when I request the same page from the flow
with cocoon.sendPageAndWait("somepage"); the handle-errors
pipeline is not invoked and no exception is thrown either.

Can anyone else confirm this?

--Tim Larson


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: Flow and map:handle-errors

Posted by Vadim Gritsenko <va...@verizon.net>.
Sylvain Wallez wrote:

> The flow uses an internal redirect to handle an external request. This 
> means that the propagated exception is only catched by the top-level 
> Cocoon object which outputs the default error page (if configured to 
> do so). So we can say that the behaviour of not executing error 
> handlers for internal requests is not suitable for internal redirects.


Can you clarify something first. If exception has happened during 
<map:call function="..."/> processing (which called some other internal 
resource, but it does not matter right now), will sitemap catch this 
exception and proceed to the <map:handle-erorrs/>?

If yes: what's the issue than? Use handle-errors!
If no: we clearly have the bug of enormous size! :)

Vadim



Re: Flow and map:handle-errors

Posted by Vadim Gritsenko <va...@verizon.net>.
Sylvain Wallez wrote:

>>> There are 2 solutions to solve this :
>>> 1/ apply the same policy for internal redirects than the one that 
>>> was active before the redirect (i.e. handle errors on internal 
>>> redirects resulting from external requests)
>>

This totally makes sense.


>>> 2/ let the user choose the behaviour through the a new attribute 
>>> such as handle-internal="true" on <handle-errors>.
>>

Might be unnecessary complication.
...

> I would say that 1/ is required as it can be considered as a bug.


Agreed.

Vadim



Re: Flow and map:handle-errors

Posted by Sylvain Wallez <sy...@anyware-tech.com>.
Timothy Larson wrote:

>--- Sylvain Wallez <sy...@anyware-tech.com> wrote:
>  
>
>>Error-handlers are not invoked on internal requests, which is what the 
>>flow uses behind sendPage[AndWait](). In that case, the exception are 
>>propagated.
>>    
>>
>
>How do you catch these exceptions in a flowscript?  I tried a simple
>  try{sendPageAndWait(some-page-with-an-error)}
>  catch(){sendPageAndWait(some-custom-error-page}
>but the catch never caught an exception.  Instead I just got the standard
>error page in the browser.
>  
>

That's because processing of the page occurs outside of the scope of the 
flowscript. There's no way to catch this in the flow.

>>Internal requests are created in 2 circumstances :
>>- use of SitemapSource: SourceResolver.resolveURI("cocoon:/blah")
>>- use of internal redirects: <map:redirect-to uri="cocoon:/blah"/> or 
>>Redirector.redirect("cocoon:/blah")
>>
>>The flow uses an internal redirect to handle an external request. This 
>>means that the propagated exception is only catched by the top-level 
>>Cocoon object which outputs the default error page (if configured to do 
>>so). So we can say that the behaviour of not executing error handlers 
>>for internal requests is not suitable for internal redirects.
>>    
>>
>
>Does this mean that we cannot catch the exception from the flowscript?
>That would be bad.
>

Yep. We cannot for two reasons :
- we cannot catch exceptions after an internal redirect (in e.g. an 
action) because the redirection is handled when going back in the 
sitemap engine from the component having done the redirect,
- we cannot because sendPageAndWait() creates a continuation that halts 
execution of the flow script.

>>There are 2 solutions to solve this :
>>1/ apply the same policy for internal redirects than the one that was 
>>active before the redirect (i.e. handle errors on internal redirects 
>>resulting from external requests)
>>2/ let the user choose the behaviour through the a new attribute such as 
>>handle-internal="true" on <handle-errors>.
>>
>>Thinking further, these 2 solutions are complementary if we consider 
>>that 2/ applies only to internal requests produced by the SitemapSource.
>>
>>What do you think ?
>>    
>>
>
>I personally would be happy if the flowscript could catch errors as
>exceptions and create its own responses, such as sending an alternate page
>or an error page.
>
>It would be nice to also have the option of letting the sitemap handle-errors
>pipeline take care of it, but I am not too worried about this if I can get my
>first wish.  I guess this last part is asking for a way to make solution 1
>optional, possibly per call to sendPage[AndWait](), but I am not sure since
>my current use case gives me no hints.
>

Yep. But you can't get your first wish...

I would say that 1/ is required as it can be considered as a bug. For 2/ 
this is a new feature that has to be discussed.

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com



Re: Flow and map:handle-errors

Posted by Timothy Larson <ti...@yahoo.com>.
--- Sylvain Wallez <sy...@anyware-tech.com> wrote:
> Error-handlers are not invoked on internal requests, which is what the 
> flow uses behind sendPage[AndWait](). In that case, the exception are 
> propagated.

How do you catch these exceptions in a flowscript?  I tried a simple
  try{sendPageAndWait(some-page-with-an-error)}
  catch(){sendPageAndWait(some-custom-error-page}
but the catch never caught an exception.  Instead I just got the standard
error page in the browser.

> Internal requests are created in 2 circumstances :
> - use of SitemapSource: SourceResolver.resolveURI("cocoon:/blah")
> - use of internal redirects: <map:redirect-to uri="cocoon:/blah"/> or 
> Redirector.redirect("cocoon:/blah")
> 
> The flow uses an internal redirect to handle an external request. This 
> means that the propagated exception is only catched by the top-level 
> Cocoon object which outputs the default error page (if configured to do 
> so). So we can say that the behaviour of not executing error handlers 
> for internal requests is not suitable for internal redirects.

Does this mean that we cannot catch the exception from the flowscript?
That would be bad.

> There are 2 solutions to solve this :
> 1/ apply the same policy for internal redirects than the one that was 
> active before the redirect (i.e. handle errors on internal redirects 
> resulting from external requests)
> 2/ let the user choose the behaviour through the a new attribute such as 
> handle-internal="true" on <handle-errors>.
>
> Thinking further, these 2 solutions are complementary if we consider 
> that 2/ applies only to internal requests produced by the SitemapSource.
> 
> What do you think ?

I personally would be happy if the flowscript could catch errors as
exceptions and create its own responses, such as sending an alternate page
or an error page.

It would be nice to also have the option of letting the sitemap handle-errors
pipeline take care of it, but I am not too worried about this if I can get my
first wish.  I guess this last part is asking for a way to make solution 1
optional, possibly per call to sendPage[AndWait](), but I am not sure since
my current use case gives me no hints.

--Tim Larson


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: Flow and map:handle-errors

Posted by Sylvain Wallez <sy...@anyware-tech.com>.
Timothy Larson wrote:

>If I request a page where the pipeline encounters an error (e.g. file not found) then the handle-errors pipeline is invoked. However, when I request the same page from the flow with cocoon.sendPageAndWait("somepage"); the handle-errors pipeline is not invoked and no exception is thrown either.
>
>Can anyone else confirm this?
>  
>

Error-handlers are not invoked on internal requests, which is what the 
flow uses behind sendPage[AndWait](). In that case, the exception are 
propagated.

Internal requests are created in 2 circumstances :
- use of SitemapSource: SourceResolver.resolveURI("cocoon:/blah")
- use of internal redirects: <map:redirect-to uri="cocoon:/blah"/> or 
Redirector.redirect("cocoon:/blah")

The flow uses an internal redirect to handle an external request. This 
means that the propagated exception is only catched by the top-level 
Cocoon object which outputs the default error page (if configured to do 
so). So we can say that the behaviour of not executing error handlers 
for internal requests is not suitable for internal redirects.

There are 2 solutions to solve this :
1/ apply the same policy for internal redirects than the one that was 
active before the redirect (i.e. handle errors on internal redirects 
resulting from external requests)
2/ let the user choose the behaviour through the a new attribute such as 
handle-internal="true" on <handle-errors>.

Thinking further, these 2 solutions are complementary if we consider 
that 2/ applies only to internal requests produced by the SitemapSource.

What do you think ?

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com