From 9535df48cc9745eff1b4665477a0f89c4d2aa23e Mon Sep 17 00:00:00 2001 From: Marc Velmer Date: Thu, 4 Jul 2024 12:18:47 +0200 Subject: [PATCH] Added raw data to `fetchElection` when function throws error --- src/services/election.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/services/election.ts b/src/services/election.ts index 09b86800..d830d752 100644 --- a/src/services/election.ts +++ b/src/services/election.ts @@ -154,7 +154,16 @@ export class ElectionService extends Service implements ElectionServicePropertie throw err; }); - const electionInfo = this.decryptMetadata(electionInformation, password); + let electionInfo, censusInfo; + try { + electionInfo = this.decryptMetadata(electionInformation, password); + censusInfo = await this.buildCensus(electionInfo); + } catch (e) { + e.electionId = electionId; + e.raw = electionInformation; + console.log(e); + throw e; + } const electionParameters = { id: electionInfo.electionId, @@ -166,7 +175,7 @@ export class ElectionService extends Service implements ElectionServicePropertie meta: electionInfo.metadata?.meta, startDate: electionInfo.startDate, endDate: electionInfo.endDate, - census: await this.buildCensus(electionInfo), + census: censusInfo, maxCensusSize: electionInfo.census.maxCensusSize, manuallyEnded: electionInfo.manuallyEnded, fromArchive: electionInfo.fromArchive,