From 377d5dadb2a14cb2d70e0b2dc77026f51b3fb51c Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 7 Apr 2021 16:38:20 +0200 Subject: [PATCH] Potential fix for all remaining errors ref #190 --- src/models/responses/ResponseStatsOrganization.ts | 12 ++++++++++-- src/models/responses/ResponseStatsTeam.ts | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/models/responses/ResponseStatsOrganization.ts b/src/models/responses/ResponseStatsOrganization.ts index 5339b55..89257a6 100644 --- a/src/models/responses/ResponseStatsOrganization.ts +++ b/src/models/responses/ResponseStatsOrganization.ts @@ -49,7 +49,15 @@ export class ResponseStatsOrgnisation implements IResponse { public constructor(org: RunnerOrganization) { this.name = org.name; this.id = org.id; - this.distance = org.distance; - this.donationAmount = org.distanceDonationAmount; + try { + this.distance = org.distance; + } catch { + this.distance = -1; + } + try { + this.donationAmount = org.distanceDonationAmount; + } catch { + this.donationAmount = -1; + } } } diff --git a/src/models/responses/ResponseStatsTeam.ts b/src/models/responses/ResponseStatsTeam.ts index 82e4eb9..e887483 100644 --- a/src/models/responses/ResponseStatsTeam.ts +++ b/src/models/responses/ResponseStatsTeam.ts @@ -57,7 +57,15 @@ export class ResponseStatsTeam implements IResponse { this.name = team.name; this.id = team.id; this.parent = team.parentGroup.toResponse(); - this.distance = team.distance; - this.donationAmount = team.distanceDonationAmount; + try { + this.distance = team.distance; + } catch { + this.distance = -1; + } + try { + this.donationAmount = team.distanceDonationAmount; + } catch { + this.donationAmount = -1; + } } }