cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tobia Conforto <>
Subject Re: Calling map:handle-errors from flowscript
Date Tue, 10 Jul 2007 16:49:37 GMT
Joerg Heinicke wrote:
> Tobia wrote:
> > cocoon.sendStatus(404)
> > cocoon.response.setStatus(404)
> > cocoon.response.sendError(404)
> > throw new
> > throw new"")
> >
> > 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:

	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.


	throw 'not-found'


<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 class="java.lang.Throwable" unroll="true"/>


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message