Previous Up Next


p:error

p:error — Causes an error.

Synopsis

<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 -->
</p:declare-step>

Description

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.

Errors

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

Examples

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

  1 <p:pipeline xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:my-errors="http://www.example.org/error"
                version="1.0">
    
  5   <p:try>
        <p:group>
          <p:error code="my-errors:fall-down-go-bang">
            <p:input port="source">
              <p:inline>
 10             <doc>Nothing to see here.</doc>
              </p:inline>
            </p:input>
          </p:error>
        </p:group>
 15     <p:catch name="uh-oh">
          <p:identity>
            <p:input port="source">
              <p:pipe step="uh-oh" port="error"/>
            </p:input>
 20       </p:identity>
        </p:catch>
      </p:try>
    </p:pipeline>
Output
1 <c:errors xmlns:c="http://www.w3.org/ns/xproc-step">
<c:error xmlns:my-errors="http://www.example.org/error"
name="!1.4.1.1"
type="p:error"
5 code="my-errors:fall-down-go-bang">
<doc>Nothing to see here.</doc>
</c:error>
</c:errors>

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.