1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

sentry - wrap report modifiers in a try-catch

This commit is contained in:
kumavis 2018-04-30 12:07:48 -07:00
parent 5f3f8c85fc
commit 2a8d3ea450

View File

@ -23,23 +23,14 @@ function setupRaven(opts) {
release, release,
transport: function(opts) { transport: function(opts) {
const report = opts.data const report = opts.data
// simplify certain complex error messages try {
if (report.exception && report.exception.values) { // simplify certain complex error messages (e.g. Ethjs)
report.exception.values.forEach(item => { simplifyErrorMessages(report)
let errorMessage = item.value // modify report urls
// simplify ethjs error messages rewriteReportUrls(report)
errorMessage = extractEthjsErrorMessage(errorMessage) } catch (err) {
// simplify 'Transaction Failed: known transaction' console.warn(err)
if (errorMessage.indexOf('Transaction Failed: known transaction') === 0) {
// cut the hash from the error message
errorMessage = 'Transaction Failed: known transaction'
}
// finalize
item.value = errorMessage
})
} }
// modify report urls
rewriteReportUrls(report)
// make request normally // make request normally
client._makeRequest(opts) client._makeRequest(opts)
}, },
@ -49,6 +40,23 @@ function setupRaven(opts) {
return Raven return Raven
} }
function simplifyErrorMessages(report) {
if (report.exception && report.exception.values) {
report.exception.values.forEach(item => {
let errorMessage = item.value
// simplify ethjs error messages
errorMessage = extractEthjsErrorMessage(errorMessage)
// simplify 'Transaction Failed: known transaction'
if (errorMessage.indexOf('Transaction Failed: known transaction') === 0) {
// cut the hash from the error message
errorMessage = 'Transaction Failed: known transaction'
}
// finalize
item.value = errorMessage
})
}
}
function rewriteReportUrls(report) { function rewriteReportUrls(report) {
// update request url // update request url
report.request.url = toMetamaskUrl(report.request.url) report.request.url = toMetamaskUrl(report.request.url)