If an error is raised during the evaluation of a RESTXQ function, an HTTP response with the status code 400 is generated. The response body contains the full error message and stack trace.
With the {{Function|Web|web:error}} function, you can abort query evaluation and enforce a premature HTTP responsewith the supplied status code and response body text:
<pre class="brush:xquery">