mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
app - warn on fetch errors instead of spamming sentry
This commit is contained in:
parent
3e4b11e0d7
commit
ecbab14cae
@ -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
|
||||
|
||||
|
@ -43,20 +43,18 @@ 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) => {
|
||||
await updateConversionRate () {
|
||||
try {
|
||||
const 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) {
|
||||
console.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err)
|
||||
this.setConversionRate(0)
|
||||
this.setConversionDate('N/A')
|
||||
}
|
||||
}
|
||||
|
||||
scheduleConversionInterval () {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -25,18 +25,15 @@ const getMessage = (locale, key, substitutions) => {
|
||||
return phrase
|
||||
}
|
||||
|
||||
function fetchLocale (localeName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return fetch(`./_locales/${localeName}/messages.json`)
|
||||
.then(response => response.json())
|
||||
.then(
|
||||
locale => resolve(locale),
|
||||
error => {
|
||||
log.error(`failed to fetch ${localeName} locale because of ${error}`)
|
||||
resolve({})
|
||||
}
|
||||
)
|
||||
})
|
||||
async function fetchLocale (localeName) {
|
||||
try {
|
||||
const response = await fetch(`./_locales/${localeName}/messages.json`)
|
||||
const locale = await response.json()
|
||||
return locale
|
||||
} catch (error) {
|
||||
log.error(`failed to fetch ${localeName} locale because of ${error}`)
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
Loading…
Reference in New Issue
Block a user