Skip to content

Commit 8eaf1e9

Browse files
committed
Retain error message
1 parent 3f5bc85 commit 8eaf1e9

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

extensions/ql-vscode/src/variant-analysis/store/repo-states-store.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,23 @@ export async function writeRepoStates(
2222

2323
export async function readRepoStates(
2424
storagePath: string,
25-
): Promise<Record<number, VariantAnalysisScannedRepositoryState>> {
26-
const repoStatesData: Record<
27-
number,
28-
VariantAnalysisScannedRepositoryStateData
29-
> = await readJson(storagePath);
25+
): Promise<Record<number, VariantAnalysisScannedRepositoryState> | undefined> {
26+
try {
27+
const repoStatesData: Record<
28+
number,
29+
VariantAnalysisScannedRepositoryStateData
30+
> = await readJson(storagePath);
3031

31-
// Map from repoStates Data type to the repoStates Domain type
32-
const repoStates = Object.fromEntries(
33-
Object.entries(repoStatesData).map(([key, value]) => {
34-
return [key, mapRepoStateToDomain(value)];
35-
}),
36-
);
32+
// Map from repoStates Data type to the repoStates Domain type
33+
const repoStates = Object.fromEntries(
34+
Object.entries(repoStatesData).map(([key, value]) => {
35+
return [key, mapRepoStateToDomain(value)];
36+
}),
37+
);
3738

38-
return repoStates;
39+
return repoStates;
40+
} catch (e) {
41+
// Ignore this error, we simply might not have downloaded anything yet
42+
return undefined;
43+
}
3944
}

extensions/ql-vscode/src/variant-analysis/variant-analysis-manager.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,13 @@ export class VariantAnalysisManager
264264
} else {
265265
await this.setVariantAnalysis(variantAnalysis);
266266

267-
try {
268-
const repoStates = await readRepoStates(
269-
this.getRepoStatesStoragePath(variantAnalysis.id),
270-
);
271-
this.repoStates.set(variantAnalysis.id, repoStates);
272-
} catch (e) {
273-
// Ignore this error, we simply might not have downloaded anything yet
267+
const repoStatesFromDisk = await readRepoStates(
268+
this.getRepoStatesStoragePath(variantAnalysis.id),
269+
);
270+
271+
if (repoStatesFromDisk) {
272+
this.repoStates.set(variantAnalysis.id, repoStatesFromDisk);
273+
} else {
274274
this.repoStates.set(variantAnalysis.id, {});
275275
}
276276

0 commit comments

Comments
 (0)