Previous Up Next


p:error — Causes an error.


<p:declare-step type="p:error">
     <p:input port="source" primary="false"/>
     <p:output port="result" sequence="true"/>
     <p:option name="code" required="true"/>                       <!-- QName -->
     <p:option name="code-prefix"/>                                <!-- NCName -->
     <p:option name="code-namespace"/>                             <!-- anyURI -->


The p:error step generates a dynamic error using the specified error code.

If the code value contains a colon, then its value is interpreted as a QName and there must be an in-scope namespace declaration for that prefix in the pipeline document. It is an error in this case to specify either a code-prefix or code-namespace.

This step uses the document provided on its input as the content of the error raised. A c:errors document will be produced on the error output port; it can be caught by a p:try just like any other dynamic error.

The result port on p:error is purely for authoring convenience (especially in the common case where a p:error occurs in the branch of a p:choose). The p:error step must obey all the rules with respect to its inputs and outputs even though the step is guaranteed to fail so nothing will ever appear on its result port.


Error Description
err:D0034 Occurs if code-prefix or code-namespace are used when the lexical value of the code option contains a colon.


A p:error always fails. In the example below, we catch it with a p:try.

  1 <p:pipeline xmlns:p=""
  5   <p:try>
          <p:error code="my-errors:fall-down-go-bang">
            <p:input port="source">
 10             <doc>Nothing to see here.</doc>
 15     <p:catch name="uh-oh">
            <p:input port="source">
              <p:pipe step="uh-oh" port="error"/>
 20       </p:identity>
1 <c:errors xmlns:c="">
<c:error xmlns:my-errors=""
5 code="my-errors:fall-down-go-bang">
<doc>Nothing to see here.</doc>

Without the p:try, the failure would have caused the pipeline processor to abort the pipeline. How (or if) the processor reports an error in that case is implementation-defined.