Skip to content

Commit f4ddc17

Browse files
authored
Merge pull request #1158 from github/aeisenberg/open-query-logger
Open query server logger for query errors
2 parents ebce282 + 4c411ac commit f4ddc17

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [UNRELEASED]
44

55
- Fix a bug where database upgrades could not be resolved if some of the target pack's dependencies are outside of the workspace. [#1138](https://github.com/github/vscode-codeql/pull/1138)
6+
- Open the query server logs for query errors (instead of the extension log). This will make it easier to track down query errors. [#1158](https://github.com/github/vscode-codeql/pull/1158)
67
- Fix a bug where queries took a long time to run if there are no folders in the workspace. [#1157](https://github.com/github/vscode-codeql/pull/1157)
78

89
## 1.5.11 - 10 February 2022

extensions/ql-vscode/src/commandRunner.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ export function commandRunner(
160160
export function commandRunnerWithProgress<R>(
161161
commandId: string,
162162
task: ProgressTask<R>,
163-
progressOptions: Partial<ProgressOptions>
163+
progressOptions: Partial<ProgressOptions>,
164+
outputLogger = logger
164165
): Disposable {
165166
return commands.registerCommand(commandId, async (...args: any[]) => {
166167
const startTime = Date.now();
@@ -177,16 +178,17 @@ export function commandRunnerWithProgress<R>(
177178
if (e instanceof UserCancellationException) {
178179
// User has cancelled this action manually
179180
if (e.silent) {
180-
void logger.log(errorMessage);
181+
void outputLogger.log(errorMessage);
181182
} else {
182-
void showAndLogWarningMessage(errorMessage);
183+
void showAndLogWarningMessage(errorMessage, { outputLogger });
183184
}
184185
} else {
185186
// Include the full stack in the error log only.
186187
const fullMessage = e.stack
187188
? `${errorMessage}\n${e.stack}`
188189
: errorMessage;
189190
void showAndLogErrorMessage(errorMessage, {
191+
outputLogger,
190192
fullMessage
191193
});
192194
}

extensions/ql-vscode/src/extension.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ async function activateWithInstalledDistribution(
539539
// Note we must update the query history view after showing results as the
540540
// display and sorting might depend on the number of results
541541
} catch (e) {
542+
e.message = `Error running query: ${e.message}`;
542543
item.failureReason = e.message;
543544
throw e;
544545
} finally {
@@ -639,7 +640,10 @@ async function activateWithInstalledDistribution(
639640
{
640641
title: 'Running query',
641642
cancellable: true
642-
}
643+
},
644+
645+
// Open the query server logger on error since that's usually where the interesting errors appear.
646+
queryServerLogger
643647
)
644648
);
645649
interface DatabaseQuickPickItem extends QuickPickItem {
@@ -771,7 +775,11 @@ async function activateWithInstalledDistribution(
771775
{
772776
title: 'Running queries',
773777
cancellable: true
774-
})
778+
},
779+
780+
// Open the query server logger on error since that's usually where the interesting errors appear.
781+
queryServerLogger
782+
)
775783
);
776784
ctx.subscriptions.push(
777785
commandRunnerWithProgress(
@@ -784,7 +792,10 @@ async function activateWithInstalledDistribution(
784792
{
785793
title: 'Running query',
786794
cancellable: true
787-
})
795+
},
796+
// Open the query server logger on error since that's usually where the interesting errors appear.
797+
queryServerLogger
798+
)
788799
);
789800

790801
ctx.subscriptions.push(
@@ -799,7 +810,11 @@ async function activateWithInstalledDistribution(
799810
{
800811
title: 'Running query',
801812
cancellable: true
802-
})
813+
},
814+
815+
// Open the query server logger on error since that's usually where the interesting errors appear.
816+
queryServerLogger
817+
)
803818
);
804819

805820
ctx.subscriptions.push(
@@ -810,7 +825,10 @@ async function activateWithInstalledDistribution(
810825
displayQuickQuery(ctx, cliServer, databaseUI, progress, token),
811826
{
812827
title: 'Run Quick Query'
813-
}
828+
},
829+
830+
// Open the query server logger on error since that's usually where the interesting errors appear.
831+
queryServerLogger
814832
)
815833
);
816834

0 commit comments

Comments
 (0)