Retain error message

This commit is contained in:
Nora
2023-04-06 10:07:41 +00:00
parent 3f5bc85004
commit 8eaf1e9adc
2 changed files with 24 additions and 19 deletions

View File

@@ -22,18 +22,23 @@ export async function writeRepoStates(
export async function readRepoStates(
storagePath: string,
): Promise<Record<number, VariantAnalysisScannedRepositoryState>> {
const repoStatesData: Record<
number,
VariantAnalysisScannedRepositoryStateData
> = await readJson(storagePath);
): Promise<Record<number, VariantAnalysisScannedRepositoryState> | undefined> {
try {
const repoStatesData: Record<
number,
VariantAnalysisScannedRepositoryStateData
> = await readJson(storagePath);
// Map from repoStates Data type to the repoStates Domain type
const repoStates = Object.fromEntries(
Object.entries(repoStatesData).map(([key, value]) => {
return [key, mapRepoStateToDomain(value)];
}),
);
// Map from repoStates Data type to the repoStates Domain type
const repoStates = Object.fromEntries(
Object.entries(repoStatesData).map(([key, value]) => {
return [key, mapRepoStateToDomain(value)];
}),
);
return repoStates;
return repoStates;
} catch (e) {
// Ignore this error, we simply might not have downloaded anything yet
return undefined;
}
}

View File

@@ -264,13 +264,13 @@ export class VariantAnalysisManager
} else {
await this.setVariantAnalysis(variantAnalysis);
try {
const repoStates = await readRepoStates(
this.getRepoStatesStoragePath(variantAnalysis.id),
);
this.repoStates.set(variantAnalysis.id, repoStates);
} catch (e) {
// Ignore this error, we simply might not have downloaded anything yet
const repoStatesFromDisk = await readRepoStates(
this.getRepoStatesStoragePath(variantAnalysis.id),
);
if (repoStatesFromDisk) {
this.repoStates.set(variantAnalysis.id, repoStatesFromDisk);
} else {
this.repoStates.set(variantAnalysis.id, {});
}