Skip to content

Commit 793b823

Browse files
committed
Rename variable and tweak error display
1 parent b3abff3 commit 793b823

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

extensions/ql-vscode/src/extension.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,11 @@ async function activateWithInstalledDistribution(
468468
selectedQuery: Uri | undefined,
469469
progress: ProgressCallback,
470470
token: CancellationToken,
471-
databaseQuickPick: DatabaseItem | undefined,
471+
databaseItem: DatabaseItem | undefined,
472472
): Promise<void> {
473473
if (qs !== undefined) {
474-
const dbItem = databaseQuickPick !== undefined
475-
// database selected from multi-database quick pick
476-
? databaseQuickPick
477-
// database currently selected in Databases UI
478-
: await databaseUI.getDatabaseItem(progress, token);
474+
// If no databaseItem is specified, use the database currently selected in the Databases UI
475+
const dbItem = databaseItem || await databaseUI.getDatabaseItem(progress, token);
479476
if (dbItem === undefined) {
480477
throw new Error('Can\'t run query without a selected database');
481478
}
@@ -588,14 +585,23 @@ async function activateWithInstalledDistribution(
588585
{ canPickMany: true }
589586
);
590587
if (quickpick !== undefined) {
588+
// Collect all skipped databases and display them at the end (instead of popping up individual errors)
589+
const skippedDatabases = [];
590+
const errors = [];
591591
for (const item of quickpick) {
592592
try {
593593
await compileAndRunQuery(false, uri, progress, token, item.databaseItem);
594594
} catch (error) {
595-
// Skip databases that are incompatible with the query, e.g. using a different language.
596-
void helpers.showAndLogErrorMessage(`Skipped database '${item.label}'. ${error}`);
595+
skippedDatabases.push(item.label);
596+
errors.push(error.message);
597597
}
598598
}
599+
if (skippedDatabases.length > 0) {
600+
void logger.log(`Errors:\n${errors.join('\n')}`);
601+
void helpers.showAndLogWarningMessage(
602+
`The following databases were skipped:\n${skippedDatabases.join('\n')}.\nFor details about the errors, see the logs.`
603+
);
604+
}
599605
} else {
600606
void helpers.showAndLogErrorMessage('No databases selected.');
601607
}

extensions/ql-vscode/src/run-queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ export async function compileAndRunQueryAgainstDatabase(
563563
const dbSchemaName = path.basename(db.contents.dbSchemeUri.fsPath);
564564
if (querySchemaName != dbSchemaName) {
565565
void logger.log(`Query schema was ${querySchemaName}, but database schema was ${dbSchemaName}.`);
566-
throw new Error(`The query ${path.basename(queryPath)} cannot be run against the selected database: their target languages are different. Please select a different database and try again.`);
566+
throw new Error(`The query ${path.basename(queryPath)} cannot be run against the selected database (${db.name}): their target languages are different. Please select a different database and try again.`);
567567
}
568568

569569
const qlProgram: messages.QlProgram = {

0 commit comments

Comments
 (0)