Changes

Jump to navigation Jump to search
372 bytes added ,  12:38, 25 February 2021
no edit summary
All RESTXQ [[XQuery 3.0#Annotations|annotations]] are assigned to the <code><nowiki>http://exquery.org/ns/restxq</nowiki></code> namespace, which is statically bound to the {{Code|rest}} prefix. A ''Resource Function'' is an XQuery function that has been marked up with RESTXQ annotations. When an HTTP request comes in, a resource function will be invoked that matches the constraints indicated by its annotations.
If a RESTXQ URL is requested, the {{Option|RESTXQPATH}} module directory and its sub-directories will be traversed, and all [[XQuery Extensions#Suffixes|XQuery files]] will be parsed for functions with RESTXQ annotations. Sub-directories that include an {{Code|.ignore}} file will be skipped. In addition, XQuery modules that cannot be parsed will be ignored if {{Option|RESTXQERRORS}} is enabled.
To speed up processing, the functions of the existing XQuery modules are automatically cached in main memory:
=Error Handling=
==Raise Errors=={{Mark|Updated with BaseX 9.5:}} Status code {{Code|400}} changed to {{Code|500}}; omit stack trace.
{{Mark|Updated If an error is raised during the evaluation of a RESTXQ function, an HTTP response with BaseX 9.5:}} Status the status code {{Code|400}} changed to {{Code|500}}, omit stack traceis generated.
If an error By default, server-side errors in the RESTXQ application will be passed on to the client. This is raised particularly helpful during the evaluation of a RESTXQ functiondevelopment process. In productive environment, however, an HTTP response with it is advisable not to expose errors to the status code 500 is generatedclient. The response body contains This can be realized via the full error message and stack trace unless {{Option|RESTXQERRORS}} is option. If disabled.,
* XQuery modules that cannot be parsed will be ignored and* full error messages and stack traces will be suppressed and not included in the HTTP response. ==Raise Errors== With the {{Function|Web|web:error}} function, you can abort query evaluation and , enforce a premature HTTP response with and report errors back to the supplied status code and response body text (and no stack trace)client:
<syntaxhighlight lang="xquery">
};
</syntaxhighlight>
 
In contrast to the standard <code>fn:error</code> function, a status code can be supplied, and the response body will only contain the specified error message and no stack trace.
==Catch XQuery Errors==
XQuery runtime errors can be processed via ''error annotations''.Error annotations have one or more arguments, which represent the error codes to be caught.The codes equal the names of the XQuery 3.0 [[XQuery 3.0#Try.2FCatch|try/catch]] construct:
{| class="wikitable"
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu