Skip to content

Commit 3afb878

Browse files
ssambasuMarkLogic Builder
authored andcommitted
Check if error is a plugin error
1 parent 3ef6c8b commit 3afb878

File tree

2 files changed

+11
-2
lines changed
  • marklogic-data-hub/src/main/resources/ml-modules/root/marklogic.rest.resource

2 files changed

+11
-2
lines changed

marklogic-data-hub/src/main/resources/ml-modules/root/marklogic.rest.resource/flow/assets/resource.xqy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,12 @@ 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()
170174
let $resp :=
171-
if (trace:get-error-count() > 0) then
175+
if (trace:get-error-count() > 0 and $is-plugin-error) then
172176
fn:error((),"RESTAPI-SRVEXERR", (400, "Plugin error", text{$output}))
173177
else
174178
$output

marklogic-data-hub/src/main/resources/ml-modules/root/marklogic.rest.resource/sjsFlow/assets/resource.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)