
infodev:handle-error( $ticket-id as xs:string, $context as xs:string, $error as element(error:error), [$annotation as element(info:annotation)?], [$error-log-level as xs:string?] ) as empty-sequence()
[DEPRECATED] This function provides configuration-aware error handling. If the error is to be logged,
a infodev:error element is logged to the App-Services database,
including document source-location, error code, and other information necessary to find
and fix the error. Must be used within a try-catch block.
xquery version "1.0-ml";
import module namespace info = "http://marklogic.com/appservices/infostudio"
at "/MarkLogic/appservices/infostudio/info.xqy";
import module namespace infodev = "http://marklogic.com/appservices/infostudio/dev"
at "/MarkLogic/appservices/infostudio/infodev.xqy";
declare namespace error = "http://marklogic.com/xdmp/error";
declare function local:load-doc(
$doc
) as xs:string
{
let $document := xdmp:document-get($doc)
let $path := "/xml/my.xml"
let $annotation := <info:annotation>Adding new docs to newdocs</info:annotation>
let $ticket := infodev:ticket-create($annotation, "myDB", "default", ())
let $deltas :=
<options xmlns="http://marklogic.com/appservices/infostudio">
<uri>
<literal>http://test</literal>
<path/>
<filename/>
<literal>.</literal>
<ext/>
</uri>
</options>
let $ingestion :=
try {
infodev:ingest($document, $path, $ticket),
infodev:log-progress(
$ticket,
<info:annotation>my.xml doc inserted</info:annotation>)
} catch($e) {
infodev:handle-error($ticket, $path, $e)
}
let $_ := infodev:ticket-set-status($ticket, "completed")
return (fn:concat($path, " loaded into myDB") )
};
local:load-doc("C:\test\my.xml")
(: Logs any errors encountered when loading my.xml into the database. :)
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.