cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tobia Conforto <tobia.confo...@linux.it>
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 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


Mime
View raw message