From ddb70a89ad99527e03844d23e7c0f3522e98a602 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 11 Jul 2018 18:55:02 -0700 Subject: Do not crash on NaN, and provide default --- packages/website/ts/utils/utils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index e515cdeb3..1d669d8f0 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -28,8 +28,8 @@ import { } from 'ts/types'; import { configs } from 'ts/utils/configs'; import { constants } from 'ts/utils/constants'; +import { errorReporter } from 'ts/utils/error_reporter'; import * as u2f from 'ts/vendor/u2f_api'; -import { errorReporter } from './error_reporter'; const isDogfood = (): boolean => _.includes(window.location.href, configs.DOMAIN_DOGFOOD); @@ -391,7 +391,11 @@ export const utils = { const format = `0,0.${_.repeat('0', precision)}`; const formattedAmount = numeral(unitAmount).format(format); if (_.isNaN(formattedAmount)) { - throw new Error(`amount ${BigNumber}, decimals ${decimals} could not be formatted and returned NaN.`); + // tslint:disable-next-line:no-floating-promises + errorReporter.reportAsync( + new Error(`amount ${BigNumber}, decimals ${decimals} could not be formatted and returned NaN.`), + ); + return format; } return formattedAmount; }, -- cgit v1.2.3