Skip to content

Commit 053668d

Browse files
committed
CL now throws correctly when it fails.
Signed-off-by: worksofliam <[email protected]>
1 parent ceabe1c commit 053668d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/views/results/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ async function runMultipleHandler(mode: `all`|`selected`|`from`) {
226226
try {
227227
await runHandler(statementInfo);
228228
} catch (e) {
229-
vscode.window.showErrorMessage(`Error running statement: ${e instanceof Error ? e.message : e}`);
229+
// No error needed. runHandler still shows an error.
230230
break;
231231
}
232232
}
@@ -305,7 +305,11 @@ async function runHandler(options?: StatementInfo) {
305305
const command = statementDetail.content.split(` `)[0].toUpperCase();
306306

307307
chosenView.setLoadingText(`Running CL command... (${command})`, false);
308-
await JobManager.runSQLVerbose(statementDetail.content, {isClCommand: true}); // Can throw
308+
// CL does not throw
309+
const result = await JobManager.runSQLVerbose<{SUMMARY: string}>(statementDetail.content, {isClCommand: true});
310+
if (!result.success) {
311+
throw new Error(result.data && result.data[0] ? result.data[0].SUMMARY : `CL command ${command} executed successfully.`);
312+
}
309313

310314
} else {
311315
if (inWindow) {
@@ -318,7 +322,7 @@ async function runHandler(options?: StatementInfo) {
318322
// If it's a basic statement, we can let it scroll!
319323
if (statementDetail.noUi) {
320324
chosenView.setLoadingText(`Running SQL statement... (${possibleTitle})`, false);
321-
await JobManager.runSQLVerbose(statementDetail.content, undefined, 1);
325+
await JobManager.runSQL(statementDetail.content, undefined, 1);
322326

323327
} else {
324328
if (inWindow) {
@@ -445,7 +449,7 @@ async function runHandler(options?: StatementInfo) {
445449
errorText = e.message || `Error running SQL statement.`;
446450
}
447451

448-
if ([`statement`, `explain`, `onlyexplain`].includes(statementDetail.qualifier) && statementDetail.history !== false) {
452+
if ([`statement`, `explain`, `onlyexplain`, `cl`].includes(statementDetail.qualifier) && statementDetail.history !== false) {
449453
chosenView.setError(errorText);
450454
} else {
451455
vscode.window.showErrorMessage(errorText);

0 commit comments

Comments
 (0)