ModifyPlan.prototype.onError( action as string, [errorColumn as ColumnIdentifier?] ) as ModifyPlan
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. The column can be named with a string or a column function such as op.col, op.viewCol, or op.schemaCol. If this parameter is not passed in 'sys.errors' is used. |
onError
is a method of the following class:
// 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()
// Add an conflicting update error to the second row. Execution stops and error is raised 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("fail") .result()
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.