<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.error.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.error</api:function-name><api:suggest>fn.error</api:suggest><api:suggest>fn</api:suggest><api:suggest>error</api:suggest><api:function-link mode="xquery" fullname="fn:error">/apidoc/8.0/fn:error.xml</api:function-link><api:function mode="javascript" name="error" type="builtin" lib="fn" category="Error and Trace" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.error"><api: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 <a href="http://www.w3.org/TR/xpath-functions/#func-error" xmlns="http://www.w3.org/1999/xhtml">http://www.w3.org/TR/xpath-functions/#func-error</a>.
</api:summary><api:params><api:param name="error" type="xs:QName?" optional="true"><api:param-description>
  Error code, as an <code xmlns="http://www.w3.org/1999/xhtml">xs:QName</code>.  Note that this parameter does not
  exist in 0.9-ml.
  </api:param-description><api:param-name>error</api:param-name><api:param-type>xs.QName?</api:param-type></api:param><api:param name="description" type="xs:string" optional="true"><api:param-description>
  String description to be printed with the error.
  </api:param-description><api:param-name>description</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="data" type="item()*" optional="true"><api:param-description>
  Parameters to the error message.
  </api:param-description><api:param-name>data</api:param-name><api:param-type>ValueIterator</api:param-type></api:param></api:params><api:return>null</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
var x = xdmp.random(100);
var res = new Array();
if ( x &gt; 50 ) { 
  fn.error(xs.QName("ERROR"), "greater than 50") }
else { res.push("Less than or equal to 50") };
res.push(": no error was thrown");
fn.concat(res[0], res[1]);


=&gt; The error when the random number is greater
   than 50, otherwise a string.
</pre>
</api:example></api:function></api:function-page>