Loading TOC...

MarkLogic Server 11.0 Product Documentation
ModifyPlan.prototype.onError

ModifyPlan.prototype.onError(
   action as string,
   errorColumn as Object?
) as ModifyPlan

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
action Valid options are: "fail" - stop processing and "continue" - add an error to the error column and continue processing.
errorColumn An optional error column which is not used in the plan. If this parameter is not passed in 'sys.errors' is used.

Usage Notes

onError is a method of the following class:

Example

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

declareUpdate()
const op = require('/MarkLogic/optic');
const docsDescriptor = [
  {uri:'/test.json',
   doc:{"desc":"test1"}},
   {uri:'/test.json',
   doc:{"desc":"test2"}},
];
op.fromDocDescriptors(docsDescriptor)
.write()
.onError("continue",op.col("myError"))
.result()
  

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