diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-04-04 01:50:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-04 01:50:03 +0800 |
commit | 11d4f3200eb68033c11aa6a57fc6e0ef2d019076 (patch) | |
tree | 54c55a8223ce9d90783b02902e60ea4fb9ba4136 /app/scripts | |
parent | 3e4b11e0d701441720bec665167984240a2aca56 (diff) | |
parent | 038ad914541c3a4e6579da5b1ac79ba41b33cfb3 (diff) | |
download | tangerine-wallet-browser-11d4f3200eb68033c11aa6a57fc6e0ef2d019076.tar tangerine-wallet-browser-11d4f3200eb68033c11aa6a57fc6e0ef2d019076.tar.gz tangerine-wallet-browser-11d4f3200eb68033c11aa6a57fc6e0ef2d019076.tar.bz2 tangerine-wallet-browser-11d4f3200eb68033c11aa6a57fc6e0ef2d019076.tar.lz tangerine-wallet-browser-11d4f3200eb68033c11aa6a57fc6e0ef2d019076.tar.xz tangerine-wallet-browser-11d4f3200eb68033c11aa6a57fc6e0ef2d019076.tar.zst tangerine-wallet-browser-11d4f3200eb68033c11aa6a57fc6e0ef2d019076.zip |
Merge pull request #3846 from MetaMask/fetch-err-warn
app - warn on fetch errors instead of spamming sentry
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/controllers/blacklist.js | 5 | ||||
-rw-r--r-- | app/scripts/controllers/currency.js | 23 | ||||
-rw-r--r-- | app/scripts/controllers/infura.js | 18 | ||||
-rw-r--r-- | app/scripts/controllers/shapeshift.js | 15 |
4 files changed, 29 insertions, 32 deletions
diff --git a/app/scripts/controllers/blacklist.js b/app/scripts/controllers/blacklist.js index 33c31dab9..df41c90c0 100644 --- a/app/scripts/controllers/blacklist.js +++ b/app/scripts/controllers/blacklist.js @@ -41,9 +41,9 @@ class BlacklistController { scheduleUpdates () { if (this._phishingUpdateIntervalRef) return - this.updatePhishingList() + this.updatePhishingList().catch(log.warn) this._phishingUpdateIntervalRef = setInterval(() => { - this.updatePhishingList() + this.updatePhishingList().catch(log.warn) }, POLLING_INTERVAL) } @@ -57,4 +57,3 @@ class BlacklistController { } module.exports = BlacklistController - diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js index 930fc52e8..36b8808aa 100644 --- a/app/scripts/controllers/currency.js +++ b/app/scripts/controllers/currency.js @@ -43,20 +43,19 @@ class CurrencyController { this.store.updateState({ conversionDate }) } - updateConversionRate () { - const currentCurrency = this.getCurrentCurrency() - return fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`) - .then(response => response.json()) - .then((parsedResponse) => { + async updateConversionRate () { + let currentCurrency + try { + currentCurrency = this.getCurrentCurrency() + const response = await fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`) + const parsedResponse = await response.json() this.setConversionRate(Number(parsedResponse.bid)) this.setConversionDate(Number(parsedResponse.timestamp)) - }).catch((err) => { - if (err) { - console.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err) - this.setConversionRate(0) - this.setConversionDate('N/A') - } - }) + } catch (err) { + log.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err) + this.setConversionRate(0) + this.setConversionDate('N/A') + } } scheduleConversionInterval () { diff --git a/app/scripts/controllers/infura.js b/app/scripts/controllers/infura.js index 10adb1004..c6b4c9de2 100644 --- a/app/scripts/controllers/infura.js +++ b/app/scripts/controllers/infura.js @@ -19,15 +19,13 @@ class InfuraController { // Responsible for retrieving the status of Infura's nodes. Can return either // ok, degraded, or down. - checkInfuraNetworkStatus () { - return fetch('https://api.infura.io/v1/status/metamask') - .then(response => response.json()) - .then((parsedResponse) => { - this.store.updateState({ - infuraNetworkStatus: parsedResponse, - }) - return parsedResponse - }) + async checkInfuraNetworkStatus () { + const response = await fetch('https://api.infura.io/v1/status/metamask') + const parsedResponse = await response.json() + this.store.updateState({ + infuraNetworkStatus: parsedResponse, + }) + return parsedResponse } scheduleInfuraNetworkCheck () { @@ -35,7 +33,7 @@ class InfuraController { clearInterval(this.conversionInterval) } this.conversionInterval = setInterval(() => { - this.checkInfuraNetworkStatus() + this.checkInfuraNetworkStatus().catch(log.warn) }, POLLING_INTERVAL) } } diff --git a/app/scripts/controllers/shapeshift.js b/app/scripts/controllers/shapeshift.js index 3d955c01f..3bbfaa1c5 100644 --- a/app/scripts/controllers/shapeshift.js +++ b/app/scripts/controllers/shapeshift.js @@ -45,18 +45,19 @@ class ShapeshiftController { }) } - updateTx (tx) { - const url = `https://shapeshift.io/txStat/${tx.depositAddress}` - return fetch(url) - .then((response) => { - return response.json() - }).then((json) => { + async updateTx (tx) { + try { + const url = `https://shapeshift.io/txStat/${tx.depositAddress}` + const response = await fetch(url) + const json = await response.json() tx.response = json if (tx.response.status === 'complete') { tx.time = new Date().getTime() } return tx - }) + } catch (err) { + log.warn(err) + } } saveTx (tx) { |