Changes

Jump to navigation Jump to search
441 bytes added ,  18:39, 22 June 2013
{{Mark|Introduced with Version 7.7:}}
XQuery runtime errors can be processed via ''error annotations''. A single argument must be supplied, which represents the QName of the error to be caught. A wildcard {{Code|*}} may be specified to catch all possible errors. Within the scope of the catch clause of the XQuery [[XQuery 3.0#Try.2FCatch|try/catch]] construct, a number of variables are implicitly declared. The variables 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 unexpected, or deliberately generated in a query, as the following example shows:
<pre class="brush:xquery">
module namespace test = 'http://basex.org/examples/test';
 
declare %rest:path('/check/{$user}') function test:check($user) {
if($user = ('jack', 'lisa'))
then 'Everything ok'
else error(xs:QName('err:user'), $user)
};
declare %rest:error('err:user') %rest:error-param('description', '{$user}') function test:user($user) { 'User "' || $user || '" is unknown'
};
</pre>
<pre class="brush:xquery">
module namespace test = 'http://basex.org/examples/test';
 
declare %output:method("html") %rest:path("/error404")
function test:error404()
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu