You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Tobia Conforto <to...@linux.it> on 2007/07/10 18:49:37 UTC
Re: Calling map:handle-errors from flowscript
Joerg Heinicke wrote:
> Tobia wrote:
> > cocoon.sendStatus(404)
> > cocoon.response.setStatus(404)
> > cocoon.response.sendError(404)
> > throw new Packages.java.io.FileNotFoundException()
> > throw new Packages.org.apache.cocoon.ResourceNotFoundException("")
> >
> > The problem with the (send|set)(Status|Error) is that they don't
> > invoke the exception handlers defined in the sitemap. The problem
> > with throwing new exceptions is that they are wrapped in a
> > JavaScriptException and thus are reported as a 500 error, while I
> > need a 404.
>
> Did you have a look at the documentation?
> It talks about "unrolling" an exception. Does this work?
It doesn't seem to work, or I can't get it to work. Throwing a new
ResourceNotFoundException produces the following Java stacktrace:
org.mozilla.javascript.JavaScriptException
Caused by: org.mozilla.javascript.WrappedException
Caused by: org.apache.cocoon.ProcessingException
Caused by: org.mozilla.javascript.JavaScriptException
The exception selector is configured to unroll as much as possible, but
the JavaScriptException seems to be "unrollable".
Anyways, I solved the problem using the XPathExceptionSelector.
Flowscript:
throw 'not-found'
Sitemap:
<selector name="exception" src="org.apache.cocoon.selection.XPathExceptionSelector">
<exception name="not-found" class="org.apache.cocoon.ResourceNotFoundException"/>
<exception name="flowscript" class="org.mozilla.javascript.JavaScriptException">
<xpath name="not-found" test="starts-with(message, 'not-found ')"/>
</exception>
<exception class="java.lang.Throwable" unroll="true"/>
</selector>
Tobia
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Calling map:handle-errors from flowscript
Posted by Tobia Conforto <to...@linux.it>.
Joerg Heinicke wrote:
> Tobia Conforto wrote:
> > throw new Packages.org.apache.cocoon.ResourceNotFoundException("")
> >
> > produces the following Java stacktrace:
> >
> > org.mozilla.javascript.JavaScriptException
> > Caused by: org.mozilla.javascript.WrappedException
> > Caused by: org.apache.cocoon.ProcessingException
> > Caused by: org.mozilla.javascript.JavaScriptException
>
> This looks familiar: https://issues.apache.org/jira/browse/COCOON-1205.
> The exceptions are not kept, but swallowed. Can you confirm this?
It doesn't look like the same thing to me, but I'm not sure.
Tobia
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Calling map:handle-errors from flowscript
Posted by Joerg Heinicke <jo...@gmx.de>.
On 10.07.2007 12:49, Tobia Conforto wrote:
> It doesn't seem to work, or I can't get it to work. Throwing a new
> ResourceNotFoundException produces the following Java stacktrace:
>
> org.mozilla.javascript.JavaScriptException
> Caused by: org.mozilla.javascript.WrappedException
> Caused by: org.apache.cocoon.ProcessingException
> Caused by: org.mozilla.javascript.JavaScriptException
This looks familiar: https://issues.apache.org/jira/browse/COCOON-1205.
The exceptions are not kept, but swallowed. Can you confirm this?
Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org