Loading TOC...

MarkLogic Server 11.0 Product Documentation
op:on-error

op:on-error(
   $plan as map:map,
   $action as xs:string,
   $error-column as item()?
) as map:map

Summary

Add an error-handler to the Optic Pipeline to catch Optic Update runtime errors. The runtime errors are added in the errors column. If no error occurred the value of the error column is null. When added, the error-handler should be the last operator before op:result.

Parameters
$plan The Optic Plan. You can either use the XQuery => chaining operator or specify the variable that captures the return value from the previous operation.
$action Valid options are: "fail" - stop processing and "continue" - add an error to the error column and continue processing.
$error-column An optional error column which is not used in the plan. If this parameter is not passed in 'sys.errors' is used.

Example

(: Add an conflicting update error to the second row. The error column of the first rows returns null (no error). :)

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";
declare option xdmp:update "true";
op:from-doc-descriptors(
  (map:entry("uri", '/test.xml')
    =>map:with("doc", <doc>test1</doc>) ,
  map:entry("uri", '/test.xml')
    =>map:with("doc", <doc>test2</doc>))
  )
=>op:write()
=>op:on-error("continue",op:col("myError"))
=>op:result()
  

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