Skip to content

Commit 65bad4e

Browse files
authored
Merge pull request #182 from intersystems-community/studio-actions-reject-progress
reject progress if error in studio actions happens
2 parents 1701341 + 6f78c11 commit 65bad4e

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

src/commands/studio.ts

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -250,39 +250,42 @@ class StudioActions {
250250
title: `Executing user action: ${action.label}`,
251251
},
252252
() => {
253-
return new Promise((resolve) => {
254-
this.api
255-
.actionQuery(query, parameters)
256-
.then(async (data) => {
257-
if (action.save) {
258-
await this.processSaveFlag(action.save);
259-
}
260-
if (!afterUserAction) {
261-
outputConsole(data.console);
262-
}
263-
const actionToProcess = data.result.content.pop();
253+
return this.api
254+
.actionQuery(query, parameters)
255+
.then(async (data) => {
256+
if (action.save) {
257+
await this.processSaveFlag(action.save);
258+
}
259+
if (!afterUserAction) {
260+
outputConsole(data.console);
261+
}
262+
if (!data.result.content.length) {
263+
// nothing to-do, just ignore it
264+
return;
265+
}
266+
const actionToProcess = data.result.content.pop();
264267

265-
// CSP pages should not have a progress bar
266-
if (actionToProcess.action === 2) {
267-
resolve();
268-
}
269-
return actionToProcess;
270-
})
271-
.then(this.processUserAction)
272-
.then((answer) => {
273-
if (answer) {
274-
return answer.msg || answer.msg === ""
268+
// CSP pages should not have a progress bar
269+
if (actionToProcess.action === 2) {
270+
return;
271+
}
272+
return actionToProcess;
273+
})
274+
.then(
275+
(actionToProcess) =>
276+
actionToProcess &&
277+
this.processUserAction(actionToProcess).then((answer) =>
278+
answer && (answer.msg || answer.msg === "")
275279
? this.userAction(action, true, answer.answer, answer.msg, type)
276-
: this.userAction(action, true, answer, "", type);
277-
}
278-
})
279-
.then(() => resolve())
280-
.catch((err) => {
281-
console.log(err);
282-
outputChannel.appendLine(`Studio Action "${action.label}" not supported`);
283-
outputChannel.show();
284-
});
285-
});
280+
: this.userAction(action, true, answer, "", type)
281+
)
282+
)
283+
.catch((err) => {
284+
console.log(err);
285+
outputChannel.appendLine(`Studio Action "${action.label}" not supported`);
286+
outputChannel.show();
287+
return Promise.reject();
288+
});
286289
}
287290
);
288291
}

0 commit comments

Comments
 (0)