From 8c5994abc9354158d74bf2079192c7f60818f9be Mon Sep 17 00:00:00 2001 From: bitpshr Date: Thu, 26 Apr 2018 18:31:54 -0400 Subject: [PATCH] Return 0 for token rate fetch failures --- app/scripts/controllers/token-rates.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/token-rates.js b/app/scripts/controllers/token-rates.js index abeec4cc0..87d716aa6 100644 --- a/app/scripts/controllers/token-rates.js +++ b/app/scripts/controllers/token-rates.js @@ -1,4 +1,5 @@ const ObservableStore = require('obs-store') +const { warn } = require('loglevel') // By default, poll every 3 minutes const DEFAULT_INTERVAL = 180 * 1000 @@ -42,7 +43,10 @@ class TokenRatesController { const response = await fetch(`https://metamask.balanc3.net/prices?from=${address}&to=ETH&autoConversion=false&summaryOnly=true`) const json = await response.json() return json && json.length ? json[0].averagePrice : 0 - } catch (error) { } + } catch (error) { + warn(`MetaMask - TokenRatesController exchange rate fetch failed for ${address}.`, error) + return 0 + } } /**