error

error() → none

There are no arguments

Result

none

error($code as xs:QName) → none

Arguments

 

$code

xs:QName

The error code to be returned

Result

none

error($code as xs:QName?, $description as xs:string) → none

Arguments

 

$code

xs:QName?

The error code to be returned

 

$description

xs:string

An error message

Result

none

error($code as xs:QName?, $description as xs:string, $error-object as item()*) → none

Arguments

 

$code

xs:QName?

The error code to be returned

 

$description

xs:string

An error message

 

$error-object

item()*

An object or value associated with the error

Result

none

Links to W3C specifications

Namespace: http://www.w3.org/2005/xpath-functions

Applies to: XPath 2.0, XSLT 2.0, XQuery 1.0 and later versions

XPath 2.0 Functions and Operators

XPath 3.0 Functions and Operators

Notes on the Saxon implementation

Saxon allows the first argument to be an empty sequence, treating this as equivalent to calling fn:error() with no arguments. The error code (local part and namespace URI part) is recorded as part of the exception that's supplied to a user-defined JAXP ErrorListener, or that is returned to the calling application. The value of the $description is available by calling getMessage() on the Exception object. The error details are also available to the catch part of a call when using the XQuery 3.0 or XSLT 3.0 try/catch construct.