Skip to content

Commit 6a9c9a1

Browse files
committed
Add catch handler for discovery failures
Display a reasonable message to users if there is a failure.
1 parent f62cce3 commit 6a9c9a1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

extensions/ql-vscode/src/discovery.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DisposableObject } from './vscode-utils/disposable-object';
2+
import { showAndLogErrorMessage } from './helpers';
23

34
/**
45
* Base class for "discovery" operations, which scan the file system to find specific kinds of
@@ -9,7 +10,7 @@ export abstract class Discovery<T> extends DisposableObject {
910
private retry = false;
1011
private discoveryInProgress = false;
1112

12-
constructor() {
13+
constructor(private readonly name: string) {
1314
super();
1415
}
1516

@@ -59,6 +60,11 @@ export abstract class Discovery<T> extends DisposableObject {
5960
this.update(results);
6061
}
6162
});
63+
64+
discoveryPromise.catch(err => {
65+
showAndLogErrorMessage(`${this.name} failed. Reason: ${err.message}`);
66+
});
67+
6268
discoveryPromise.finally(() => {
6369
if (this.retry) {
6470
// Another refresh request came in while we were still running a previous discovery

extensions/ql-vscode/src/qlpack-discovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class QLPackDiscovery extends Discovery<QlpacksInfo> {
2020
private readonly workspaceFolder: WorkspaceFolder,
2121
private readonly cliServer: CodeQLCliServer
2222
) {
23-
super();
23+
super('QL Pack Discovery');
2424

2525
// Watch for any changes to `qlpack.yml` files in this workspace folder.
2626
// TODO: The CLI server should tell us what paths to watch for.

extensions/ql-vscode/src/qltest-discovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class QLTestDiscovery extends Discovery<QLTestDiscoveryResults> {
119119
private readonly workspaceFolder: WorkspaceFolder,
120120
private readonly cliServer: CodeQLCliServer
121121
) {
122-
super();
122+
super('QL Test Discovery');
123123

124124
this.push(this.qlPackDiscovery.onDidChangeQLPacks(this.handleDidChangeQLPacks, this));
125125
this.push(this.watcher.onDidChange(this.handleDidChange, this));

0 commit comments

Comments
 (0)