You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Peter van Hardenberg <pv...@uvic.ca> on 2005/10/11 08:16:22 UTC

Cocoon exception handling.

Hello,

I'm using a secondary data-driven XSLT to provide annotations for my document 
pages (thanks, Conal) but when the annotations are not present, it throws an 
exception which kills the pipeline. 

Now, I thought the best way to deal with that would be to handle the exception 
in the annotation pipeline, detect when the file is missing and simply return 
an ID transform instead of one that does something.

Unfortunately, I can't get it to work at all. I simply can't get the 
"identity.xslt" to ever get returned! I would be very appreciative of any 
advice you guys can give.

Thanks in advance,

Peter van Hardenberg
University of Victoria, Canada

<!--- bits of my sitemap follow -->
    <map:generators default="file">
      <map:generator name="exception" 
src="org.apache.cocoon.samples.errorhandling.ExceptionGenerator"/>
    </map:generators>
    <map:selectors default="browser">
      <map:selector name="exception" 
src="org.apache.cocoon.selection.XPathExceptionSelector">
        <exception name="validation" 
class="org.apache.cocoon.samples.errorhandling.ValidationException"/>
        <exception name="not-found" 
class="org.apache.cocoon.ResourceNotFoundException"/>
        <exception name="missing-source" 
class="java.io.FileNotFoundException"/>
        <exception class="java.lang.Throwable" unroll="true"/>
      </map:selector>
    </map:selectors>
    <map:actions>
      <map:action name="exception" 
src="org.apache.cocoon.samples.errorhandling.ExceptionAction"/>
    </map:actions>
  </map:components>

   <!-- annotations stylesheet creation -->
   <map:pipeline>
    <map:match pattern="annotate/*"> 
	 <map:generate src="content/{1}_ann.xml"/>
         <map:transform type="xslt-saxon" 
src="style/annotations-to-stylesheet.xslt"/>
         <map:serialize type="xml"/>
    </map:match>
    <map:handle-errors>
      <map:select type="exception">
        <map:when test="missing-source">
         <!-- in the event of an emergency (no annotations), just return the 
identity transform -->
 	 <map:generate src="style/identity.xslt"/>
 	 <map:serialize type="xml"/>
	</map:when>
      </map:select>
    </map:handle-errors>
   </map:pipeline>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon exception handling.

Posted by Jason Johnston <co...@lojjic.net>.
> On October 11, 2005 06:16 am, Jason Johnston wrote:
>> Peter van Hardenberg wrote:
>> > Hello,
>> >
>> > I'm using a secondary data-driven XSLT to provide annotations for my
>> > document pages (thanks, Conal) but when the annotations are not
>> present,
>> > it throws an exception which kills the pipeline.
>> >
>> > Now, I thought the best way to deal with that would be to handle the
>> > exception in the annotation pipeline, detect when the file is missing
>> and
>> > simply return an ID transform instead of one that does something.
>> >
>> > Unfortunately, I can't get it to work at all. I simply can't get the
>> > "identity.xslt" to ever get returned! I would be very appreciative of
>> any
>> > advice you guys can give.
>>
>> I found the following item in the release notes for 2.1.7:
>> > *) Implemented error handling for the internal requests. Error
>> handling
>> > for the \ internal requests configured using when attribute on the
>> > handle-errors element. \ Supported values are: external: This error
>> > handler should be used only on external \ requests (default);
>> internal:
>> > This error handler should be used only on internal \ requests; always:
>> > This error handler can be used for all requests. Currently, if \
>> internal
>> > error handling is enabled, only inner most error handler will be used
>> for
>> > \ errors which happened during internal pipeline processing. [VG]
>>
>> Does that help?
>>
>
> Hmm, not really. Does this imply that I need either specify one or the
> other?
> Without either, I expected it to work either way.


The description seems clear enough: by default handle-errors only works on
external requests; you can override this with when="internal" or
when="always" as appropriate for your particular case.

That said, I haven't used this feature myself, so I don't actually know
that this will work as described.  You should give it a try and see.  You
can also try searching the dev mailing list, to see if there was
discussion regarding this feature on the list, which might give more
details.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon exception handling.

Posted by Peter van Hardenberg <pv...@uvic.ca>.
On October 11, 2005 06:16 am, Jason Johnston wrote:
> Peter van Hardenberg wrote:
> > Hello,
> >
> > I'm using a secondary data-driven XSLT to provide annotations for my
> > document pages (thanks, Conal) but when the annotations are not present,
> > it throws an exception which kills the pipeline.
> >
> > Now, I thought the best way to deal with that would be to handle the
> > exception in the annotation pipeline, detect when the file is missing and
> > simply return an ID transform instead of one that does something.
> >
> > Unfortunately, I can't get it to work at all. I simply can't get the
> > "identity.xslt" to ever get returned! I would be very appreciative of any
> > advice you guys can give.
>
> I found the following item in the release notes for 2.1.7:
> > *) Implemented error handling for the internal requests. Error handling
> > for the \ internal requests configured using when attribute on the
> > handle-errors element. \ Supported values are: external: This error
> > handler should be used only on external \ requests (default); internal:
> > This error handler should be used only on internal \ requests; always:
> > This error handler can be used for all requests. Currently, if \ internal
> > error handling is enabled, only inner most error handler will be used for
> > \ errors which happened during internal pipeline processing. [VG]
>
> Does that help?
>

Hmm, not really. Does this imply that I need either specify one or the other? 
Without either, I expected it to work either way. 

-- 
Peter van Hardenberg (pvh@pvh.ca)
Victoria, BC, Canada

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon exception handling.

Posted by Jason Johnston <co...@lojjic.net>.
Peter van Hardenberg wrote:
> Hello,
> 
> I'm using a secondary data-driven XSLT to provide annotations for my document 
> pages (thanks, Conal) but when the annotations are not present, it throws an 
> exception which kills the pipeline. 
> 
> Now, I thought the best way to deal with that would be to handle the exception 
> in the annotation pipeline, detect when the file is missing and simply return 
> an ID transform instead of one that does something.
> 
> Unfortunately, I can't get it to work at all. I simply can't get the 
> "identity.xslt" to ever get returned! I would be very appreciative of any 
> advice you guys can give.


I found the following item in the release notes for 2.1.7:

> *) Implemented error handling for the internal requests. Error handling for the \
> internal requests configured using when attribute on the handle-errors element. \
> Supported values are: external: This error handler should be used only on external \
> requests (default); internal: This error handler should be used only on internal \
> requests; always: This error handler can be used for all requests. Currently, if \
> internal error handling is enabled, only inner most error handler will be used for \
> errors which happened during internal pipeline processing. [VG]

Does that help?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org