Loading TOC...

fn:error

fn:error(
   [$error as xs:QName?],
   [$description as xs:string],
   [$data as item()*]
) as empty-sequence()

Summary

[1.0 and 1.0-ml only, 0.9-ml has a different signature] Throw the given error. When an error is thrown, the XQuery program execution is stopped. For detailed semantics, see http://www.w3.org/TR/xpath-functions/#func-error.

Parameters
$error Error code, as an xs:QName. Note that this parameter does not exist in 0.9-ml.
$description String description to be printed with the error.
$data Parameters to the error message.

Example

xquery version "1.0-ml";
let $x := xdmp:random(100)
return
(
if ( $x gt 50 ) 
then ( fn:error(xs:QName("ERROR"), "greater than 50") )
else ( "Less than or equal to 50" ) ,
": no error was thrown" )

=> The error when the random number is greater
   than 50.

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.