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