==XQuery Errors==
XQuery runtime errors can be processed via ''error annotations''. A One function can only have one error annotation, and a single argument must be supplied, which represents the QName of the error codes to be caught. A wildcard Since {{CodeVersion|*7.9}} may be specified to catch all possible errors. A function can only have a single error annotation, the following notations are supported:
<pre {| class="brush:xquerywikitable" width="100%">declare %rest:error(|- valign="*top") function page! #! Syntax! Example|-| 1| <code>prefix:name</code>| <code>err:error() FORG0001</code>|-| 1| <code>Q{uri}name</code> "An error occurred while processing your RESTXQ | <code>Q{http://www.w3.org/2005/xqt-errors}FORG0001</code!">|-};| 2| <code>prefix:*</precode>| <code>err:*<!/code>|-| 2| <code>Q{uri}*</code>| <code>Q{http://www.w3.org/2005/xqt- TODO how matching works errors}*</code>|-| 3| <code>*:name</code>| <code>*:FORG0001</code>|-| 4| <code>*</code>| <code>*</code>|}
The XQuery [[XQuery 3.0#Try.2FCatch|try/catch]] construct assigns An error information to a number of pre-defined variables (will be raised if two codes with the same precedence {{Code|code}}, {{Code|description}}, {{Code|value}}, {{Code|module}}, {{Code|line-number}}, {{Code|column-number}}, {{Code|additional#}}). These variables can be bound to variables via ''error parameter annotations'', which are specified the same way as [[#Query Parameters|query parameters]]supplied.
Similar to the [[XQuery 3.0#Try.2FCatch|try/catch]] construct, the pre-defined variables ({{Code|code}}, {{Code|description}}, {{Code|value}}, {{Code|module}}, {{Code|line-number}}, {{Code|column-number}}, {{Code|additional}}) can be bound to variables via ''error parameter annotations'', which are specified the same way as [[#Query Parameters|query parameters]]. Errors may occur unexpectedly. However, they can also be triggered by a query, as demonstrated by the following example shows:
<pre class="brush:xquery">