Skip to content

Commit

Permalink
Merge pull request #4128 from MetaMask/raven-transport-fix
Browse files Browse the repository at this point in the history
guard adainst raven erroring
  • Loading branch information
kumavis authored Apr 29, 2018
2 parents 4e7b0ff + 873f85d commit aa3dc83
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
6 changes: 5 additions & 1 deletion app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,11 @@ function setupController (initState, initLangCode) {
controller.txController.on(`tx:status-update`, (txId, status) => {
if (status !== 'failed') return
const txMeta = controller.txController.txStateManager.getTx(txId)
reportFailedTxToSentry({ raven, txMeta })
try {
reportFailedTxToSentry({ raven, txMeta })
} catch (e) {
console.error(e)
}
})

// setup state persistence
Expand Down
37 changes: 20 additions & 17 deletions app/scripts/lib/setupRaven.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,20 @@ function setupRaven(opts) {
transport: function(opts) {
const report = opts.data
// simplify certain complex error messages
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
})

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
})
}
// modify report urls
rewriteReportUrls(report)
// make request normally
Expand All @@ -52,11 +53,13 @@ function rewriteReportUrls(report) {
// update request url
report.request.url = toMetamaskUrl(report.request.url)
// update exception stack trace
report.exception.values.forEach(item => {
item.stacktrace.frames.forEach(frame => {
frame.filename = toMetamaskUrl(frame.filename)
if (report.exception && report.exception.values) {
report.exception.values.forEach(item => {
item.stacktrace.frames.forEach(frame => {
frame.filename = toMetamaskUrl(frame.filename)
})
})
})
}
}

function toMetamaskUrl(origUrl) {
Expand Down

0 comments on commit aa3dc83

Please sign in to comment.