MarkLogic Server 11.0 Product Documentation
infodev:handle-error

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()

Summary

[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.

Parameters
ticket-id The id of the ticket.
context The file that generated the error.
error The error node caught by MarkLogic Server in the try block.
annotation The description of the error.
error-log-level The error log level. The possible levels are emergency, alert, critcal, error, warning, notice, info, config, debug, fine, finer, or finest. The default level is info.

Example

  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. :) 

    
Powered by MarkLogic Server | Terms of Use | Privacy Policy