From e275049f1fabb0a7af5a274ebfc33f9c3fb279ed Mon Sep 17 00:00:00 2001 From: kontrollanten <6680299+kontrollanten@users.noreply.github.com> Date: Wed, 27 Jan 2021 09:16:04 +0100 Subject: [PATCH] fix(client/numpipe): handle Intl failure gently --- .../shared-main/angular/number-formatter.pipe.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/client/src/app/shared/shared-main/angular/number-formatter.pipe.ts b/client/src/app/shared/shared-main/angular/number-formatter.pipe.ts index cbdb0939d..3a599fd4c 100644 --- a/client/src/app/shared/shared-main/angular/number-formatter.pipe.ts +++ b/client/src/app/shared/shared-main/angular/number-formatter.pipe.ts @@ -28,10 +28,16 @@ export class NumberFormatterPipe implements PipeTransform { const calc = value / (format.max / 1000) const integralPart = Math.floor(calc) const decimalPart = NumberFormatterPipe.getDecimalForNumber(calc) - const decimalSeparator = Intl.NumberFormat(this.localeId) - .formatToParts(1.1) - .find(part => part.type === 'decimal') - .value + let decimalSeparator + + try { + decimalSeparator = Intl.NumberFormat(this.localeId) + .formatToParts(1.1) + .find(part => part.type === 'decimal') + .value + } catch (error) { + decimalSeparator = ',' + } return integralPart < 10 && decimalPart > 0 ? `${integralPart}${decimalSeparator}${decimalPart}${format.type}`