Skip to content

Commit 7ca892c

Browse files
ssambasuMarkLogic Builder
authored andcommitted
Check if error is a plugin error
1 parent a89b4f4 commit 7ca892c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/extensions/flow.xqy

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,13 @@ declare function post(
167167
"errors": $errors
168168
}
169169
}
170+
let $is-plugin-error :=
171+
for $error in json:array-values($errors)
172+
where contains(xdmp:to-json($error)/code, "DATAHUB-PLUGIN-ERROR") or contains(xdmp:to-json($error)/formatString , "DATAHUB-PLUGIN-ERROR")
173+
return fn:true()
174+
170175
let $resp :=
171-
if (trace:get-error-count() > 0) then
176+
if (trace:get-error-count() > 0 and $is-plugin-error) then
172177
fn:error((),"RESTAPI-SRVEXERR", (400, "Plugin error", text{$output}))
173178
else
174179
$output

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/extensions/sjsflow.sjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ function post(context, params, input) {
121121
"errors": errors
122122
}
123123
if(resp.errorCount > 0){
124-
fn.error(null, "RESTAPI-SRVEXERR", Sequence.from([400, "Plugin error", resp]));
124+
for (let i = 0; i < errors.length; i++) {
125+
if((errors[i].stack && errors[i].stack.includes("DATAHUB-PLUGIN-ERROR"))
126+
|| (errors[i].name && errors[i].name.includes("DATAHUB-PLUGIN-ERROR"))) {
127+
fn.error(null, "RESTAPI-SRVEXERR", Sequence.from([400, "Plugin error", resp]));
128+
}
129+
}
125130
}
126131
}
127132
else {

0 commit comments

Comments
 (0)