You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Justin Hannus <jh...@comcast.net> on 2006/03/02 21:04:50 UTC
handling errors in parts
I can't seem to get an aggregate pipeline part to respect or handle
errors correctly when an exception occurs in one of the aggregate parts.
It almost seems as if its impossible. This is whats happening...
When an exception occurs in the a pipeline which is called as one of the
<map:aggregate> part elements, the erroring pipeline or parent pipelines
do not handle the errors correctly. In fact, the <map:handle-errors> is
completely ignored. What happens is the sitemap processing continues
even after the exception occurs and, eventually the main entry matching
pipeline's <handle-errors> is invoked. This is bad because when using a
cocoon:// request as your <map:part> src any pipelines under that
cocoon:// request will continue processing as if no error has occurred
but..... you will still see the cocoon error page as if processing
actually stopped!
I have a pipeline which aggregates several other pipelines and then
writes the generated content to disk. If there is an exception in one of
the aggregate parts I need the sitemap processing to stop and handle the
exception appropriately. Instead the generated content, which has
errored and therefore invalid, is still written to disk. If I remove the
aggregate pipeline and just use a regular generator the handle-errors is
respected correctly and processing stops before writing the content.
Am I misusing the <map:aggregate> elements? Or is this the expected
behavoir?
Consider the following example:
sitemap.xmap:
<map:pipeline>
<map:match pattern="*/error-example/aggregate-pipeline">
<map:aggregate element="error-example">
<map:part src="cocoon:/{1}/error-example/sub-pipeline"/>
</map:aggregate>
<!-- comment out the aggregate above and uncomment this
generator and see the handle-errors is now respected...
<map:generate type="serverpages" src="throwException.xsp"/ -->
<!-- write the content -->
<map:transform
src="../../xslt/authoring/edit/addSourceTags.xsl">
<map:parameter name="source"
value="work/live/aggregate-pipeline.html"/>
</map:transform>
<map:transform type="write-source">
<map:parameter name="serializer" value="xhtml"/>
</map:transform>
<map:transform
src="../../xslt/authoring/edit/removeSourceTags.xsl"/>
<map:serialize/>
</map:match>
</map:pipeline>
<map:pipeline>
<map:match pattern="*/error-example/sub-pipeline">
<map:generate type="serverpages" src="throwException.xsp"/>
<map:serialize/>
</map:match>
<map:handle-errors>
<map:generate type="notifying"/>
<map:transform
src="../../../stylesheets/system/error2html.xslt">
<map:parameter name="contextPath"
value="{request:contextPath}"/>
</map:transform>
<map:serialize type="xhtml" status-code="500"/>
</map:handle-errors>
</map:pipeline>
throwException.xsp:
<xsp:page language="java"
xmlns:xsp="http://apache.org/xsp"
>
<xsp:structure>
<xsp:include>org.apache.cocoon.ProcessingException</xsp:include>
</xsp:structure>
<exception>
<xsp:content>This file should not be written</xsp:content>
<xsp:logic>
if (true) {
throw new ProcessingException("Whoops!");
}
</xsp:logic>
</exception>
</xsp:page>
Thanks so much,
--
Justin Hannus
Software Engineer | Infrastructure | Lycos Inc.
justin.hannus@lycos-inc.com
[781] 370-2988
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org