Changes

Jump to navigation Jump to search
108 bytes added ,  10:34, 21 August 2019
no edit summary
=Error Handling=
==Raise XQuery Errors== {{Mark|Updated with Version 9.3}}: If an error is raised during the evaluation of a RESTXQ function, an HTTP response with the status code 400 is generated. With the {{Function|Web|web:error}} function, you can generate responses with a custom status code: You can also define custom error codes by using the third argument of the error function… <pre class="brush:xquery">declare %rest:path("/teapot")function page:teapot() { web:error(418, "I'm a pretty teapot")};</pre> The XQuery error code and the stack trace will be suppressed in the body of the HTTP response. ==Catch XQuery Errors==
XQuery runtime errors can be processed via ''error annotations''.
</pre>
An XQuery error in a RESTXQ context delivers by default a HTTP status code 400 error back to the client. However, you can also define a custom error code by using the third argument of the error function. {{Mark|Updated with Version 9.3}}: If the error code has the RESTXQ namespace, the stack trace and the error code will be suppressed in the client output: <pre class="brush:xquery">declare %rest:path("/teapot")function page:teapot() { fn:error(xs:QName('rest:error'), "I'm a teapot", 418)};</pre> ==Catch HTTP Errors==
Errors that occur outside RESTXQ can be caught by adding {{Code|error-page}} elements with an error code and a target location to the {{Code|web.xml}} configuration file (find more details in the [http://www.eclipse.org/jetty/documentation/current/custom-error-pages.html Jetty Documentation]):
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu