Skip to content

Commit f4727fe

Browse files
Convert CachedOperation callbacks to use Error type
1 parent c906e76 commit f4727fe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

extensions/ql-vscode/src/language-support/contextual/cached-operation.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { asError } from "../../common/helpers-pure";
2+
13
/**
24
* A cached mapping from strings to value of type U.
35
*/
@@ -7,7 +9,7 @@ export class CachedOperation<U> {
79
private readonly lru: string[];
810
private readonly inProgressCallbacks: Map<
911
string,
10-
Array<[(u: U) => void, (reason?: any) => void]>
12+
Array<[(u: U) => void, (reason?: Error) => void]>
1113
>;
1214

1315
constructor(
@@ -18,7 +20,7 @@ export class CachedOperation<U> {
1820
this.lru = [];
1921
this.inProgressCallbacks = new Map<
2022
string,
21-
Array<[(u: U) => void, (reason?: any) => void]>
23+
Array<[(u: U) => void, (reason?: Error) => void]>
2224
>();
2325
this.cached = new Map<string, U>();
2426
}
@@ -46,7 +48,7 @@ export class CachedOperation<U> {
4648
}
4749

4850
// Otherwise compute the new value, but leave a callback to allow sharing work
49-
const callbacks: Array<[(u: U) => void, (reason?: any) => void]> = [];
51+
const callbacks: Array<[(u: U) => void, (reason?: Error) => void]> = [];
5052
this.inProgressCallbacks.set(t, callbacks);
5153
try {
5254
const result = await this.operation(t, ...args);
@@ -61,7 +63,7 @@ export class CachedOperation<U> {
6163
return result;
6264
} catch (e) {
6365
// Rethrow error on all callbacks
64-
callbacks.forEach((f) => f[1](e));
66+
callbacks.forEach((f) => f[1](asError(e)));
6567
throw e;
6668
} finally {
6769
this.inProgressCallbacks.delete(t);

0 commit comments

Comments
 (0)