aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-10-19 19:18:16 +0800
committerkumavis <aaron@kumavis.me>2018-10-19 19:18:16 +0800
commit31175dcb24d836650469775a50289bfc131bcd18 (patch)
tree20470a24636e8e735c18342871f047aa12c4578a /app/scripts
parenta57d267dcbfa1a75a5ce3295e51825561e42c58d (diff)
downloadtangerine-wallet-browser-31175dcb24d836650469775a50289bfc131bcd18.tar
tangerine-wallet-browser-31175dcb24d836650469775a50289bfc131bcd18.tar.gz
tangerine-wallet-browser-31175dcb24d836650469775a50289bfc131bcd18.tar.bz2
tangerine-wallet-browser-31175dcb24d836650469775a50289bfc131bcd18.tar.lz
tangerine-wallet-browser-31175dcb24d836650469775a50289bfc131bcd18.tar.xz
tangerine-wallet-browser-31175dcb24d836650469775a50289bfc131bcd18.tar.zst
tangerine-wallet-browser-31175dcb24d836650469775a50289bfc131bcd18.zip
blacklist + currency - report error via log instead of throw
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/controllers/blacklist.js7
-rw-r--r--app/scripts/controllers/currency.js10
2 files changed, 12 insertions, 5 deletions
diff --git a/app/scripts/controllers/blacklist.js b/app/scripts/controllers/blacklist.js
index 6ee89259c..e55b09d03 100644
--- a/app/scripts/controllers/blacklist.js
+++ b/app/scripts/controllers/blacklist.js
@@ -1,6 +1,7 @@
const ObservableStore = require('obs-store')
const extend = require('xtend')
const PhishingDetector = require('eth-phishing-detect/src/detector')
+const log = require('loglevel')
// compute phishing lists
const PHISHING_DETECTION_CONFIG = require('eth-phishing-detect/src/config.json')
@@ -87,7 +88,8 @@ class BlacklistController {
try {
response = await fetch('https://api.infura.io/v2/blacklist')
} catch (err) {
- throw new Error(`BlacklistController - failed to fetch blacklist:\n${err.stack}`)
+ log.error(new Error(`BlacklistController - failed to fetch blacklist:\n${err.stack}`))
+ return
}
// parse response
let rawResponse
@@ -96,7 +98,8 @@ class BlacklistController {
const rawResponse = await response.text()
phishing = JSON.parse(rawResponse)
} catch (err) {
- throw new Error(`BlacklistController - failed to parse blacklist:\n${rawResponse}`)
+ log.error(new Error(`BlacklistController - failed to parse blacklist:\n${rawResponse}`))
+ return
}
// update current blacklist
this.store.updateState({ phishing })
diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js
index 6cb39d39a..6b82265f6 100644
--- a/app/scripts/controllers/currency.js
+++ b/app/scripts/controllers/currency.js
@@ -1,5 +1,6 @@
const ObservableStore = require('obs-store')
const extend = require('xtend')
+const log = require('loglevel')
// every ten minutes
const POLLING_INTERVAL = 600000
@@ -110,7 +111,8 @@ class CurrencyController {
try {
response = await fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`)
} catch (err) {
- throw new Error(`CurrencyController - Failed to request currency from Infura:\n${err.stack}`)
+ log.error(new Error(`CurrencyController - Failed to request currency from Infura:\n${err.stack}`))
+ return
}
let rawResponse
let parsedResponse
@@ -118,7 +120,8 @@ class CurrencyController {
rawResponse = await response.text()
parsedResponse = JSON.parse(rawResponse)
} catch (err) {
- throw new Error(`CurrencyController - Failed to parse response "${rawResponse}"`)
+ log.error(new Error(`CurrencyController - Failed to parse response "${rawResponse}"`))
+ return
}
this.setConversionRate(Number(parsedResponse.bid))
this.setConversionDate(Number(parsedResponse.timestamp))
@@ -127,7 +130,8 @@ class CurrencyController {
this.setConversionRate(0)
this.setConversionDate('N/A')
// throw error
- throw new Error(`CurrencyController - Failed to query rate for currency "${currentCurrency}":\n${err.stack}`)
+ log.error(new Error(`CurrencyController - Failed to query rate for currency "${currentCurrency}":\n${err.stack}`))
+ return
}
}