| XQUERY/XSLT API DOCUMENTATION 4.2 |
All XQuery & XSLT Functions MarkLogic Built-In Functions Admin (xdmp:) AppServer (xdmp:) Classifier (cts:) Debug (dbg:) Document Conversion (xdmp:) Extension (xdmp:) Documents, Directories, Properties, and Locks Functions Extension Functions Function Values Functions HTTP Functions JSON Functions MarkLogic Server Functions Search Functions XML Functions XQuery Context Functions XSLT Functions map (map:) Math (math:) Profile (prof:) Search (cts:) cts:query Constructors Functions Geospatial Functions Geospatial Lexicon Functions Lexicon Functions Search Functions Search Clustering Functions Security (xdmp:) Server Monitoring (xdmp:) Spell (spell:) Update (xdmp:) XQuery Library Modules Admin Library (admin:) Actions Functions Appserver Functions Database Functions Forest Functions Group Functions Host Functions Mimetypes Functions Scheduler Functions Alerting (alert:) Elastic Compute Cloud (ec2:) Entity Enrichment (entity:) Flexible Replication (flexrep:) Geospatial Supporting Functions GEO Functions GeoRSS Functions GML Functions KML Functions MCGM Functions Information Studio (info:) Information Studio Developer (infodev:) Library Services (dls:) cts:query Constructor Functions Document Management Functions Document Update Functions Retention Policy Functions XInclude Functions Modular Documents XInclude Functions XPointer Functions PKI (pki:) Plugin (plugin:) Search (search:) Security-sec (sec:) Spelling Dictionary Management (spell:) Thesaurus (thsr:) Triggers (trgr:) Triggers Library (trgr:) WordProcessingML (ooxml:) ZIP Package (ooxml:) CPF Functions Content Processing Framework (cpf:) CSS Conversion (css:) DocBook Conversion (dbk:) Domains (dom:) Excel Conversion (excel:) Generic Conversion (cvt:) Links (lnk:) MSWord Conversion (msword:) PDF Conversion (pdf:) Pipelines (p:) Powerpoint Conversion (ppt:) XHTML Conversion (xhtml:) W3C-Standard Functions Accessor (fn:) AnyURI (fn:) Boolean (fn:) Context (fn:) DurationDateTime (fn:) Error and Trace (fn:) Node (fn:) Numeric (fn:) QName (fn:) Sequence (fn:) String (fn:) XSLT (fn:) W3C XQuery/XSLT Reference W3C XQuery Functions W3C XQuery Language W3C XSLT Language
This page was generated September 12, 2012 6:01 AM | XQuery & XSLT Built-In & Modules Function Reference
Built-In: Error and Trace
The error and trace built-in functions are XQuery functions defined for throwing errors from XQuery programs and debug tracing. They are defined in XQuery 1.0 and XPath 2.0 Functions and Operators. The error and trace built-in functions use the `fn` namespace prefix, which is predefined in the server. Also, the `fn` prefix is the default prefix for function calls if none is specified.
Function Summary
fn:error | [1.0 and 1.0-ml only, 0.9-ml has a different signature] Throw the given error.
fn:trace | Return the input $value unchanged and, if $label is the name of an enabled server event, emit that server event to the server log file (ErrorLog.txt) with $value as its data.
Function Detail
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 (optional): Error code, as an `xs:QName`. Note that this parameter does not exist in 0.9-ml.
$description (optional): String description to be printed with the error.
$data (optional): 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.
fn:trace(
| $value as item()*,
| $label as xs:string
) as item()*
Summary: Return the input $value unchanged and, if $label is the name of an enabled server event, emit that server event to the server log file (`ErrorLog.txt`) with $value as its data.
Parameters:
$value : The values to trace.
$label : A string label for the trace output.
Usage Notes: In order for the trace event to print out in the log file, you must enable the trace event in the Diagnostics page (Groups > group_name > Diagnostics ) of the Admin interface for the specified label.
Example:
    fn:trace("This is a trace event.", "MY TRACE EVENT")

    => If MY TRACE EVENT is defined as an enabled trace event
       in the Diagnostics page of the Admin interface, then a
       message similar to the following is added to the
       ErrorLog.txt file:

       2006-03-20 17:56:09.346 Info: [Event:id=MY TRACE EVENT]
                                     This is a trace event.

© Copyright 2002-2012 MarkLogic Corporation. All rights reserved.