diff options
author | Thomas <thomas.b.huang@gmail.com> | 2018-05-04 05:38:49 +0800 |
---|---|---|
committer | Thomas <thomas.b.huang@gmail.com> | 2018-05-04 05:38:49 +0800 |
commit | 025d8e798394fab215a3a41247d4ed2ecf865edd (patch) | |
tree | 5a245136f008d335314d772fab84c61038257d40 /app/scripts/lib/setupRaven.js | |
parent | 1d353c002ddbb636c8291f7e26cf8d8309983e86 (diff) | |
parent | 23e1290e27c165e967a4a642980abc7c18d759b1 (diff) | |
download | tangerine-wallet-browser-025d8e798394fab215a3a41247d4ed2ecf865edd.tar tangerine-wallet-browser-025d8e798394fab215a3a41247d4ed2ecf865edd.tar.gz tangerine-wallet-browser-025d8e798394fab215a3a41247d4ed2ecf865edd.tar.bz2 tangerine-wallet-browser-025d8e798394fab215a3a41247d4ed2ecf865edd.tar.lz tangerine-wallet-browser-025d8e798394fab215a3a41247d4ed2ecf865edd.tar.xz tangerine-wallet-browser-025d8e798394fab215a3a41247d4ed2ecf865edd.tar.zst tangerine-wallet-browser-025d8e798394fab215a3a41247d4ed2ecf865edd.zip |
Merge branch 'e2e-tests' of https://github.com/tmashuang/metamask-extension into e2e-tests
Diffstat (limited to 'app/scripts/lib/setupRaven.js')
-rw-r--r-- | app/scripts/lib/setupRaven.js | 61 |
1 files changed, 41 insertions, 20 deletions
diff --git a/app/scripts/lib/setupRaven.js b/app/scripts/lib/setupRaven.js index 9ec9a256f..b1b67f771 100644 --- a/app/scripts/lib/setupRaven.js +++ b/app/scripts/lib/setupRaven.js @@ -23,22 +23,16 @@ function setupRaven(opts) { release, 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 - }) - - // modify report urls - rewriteReportUrls(report) + try { + // handle error-like non-error exceptions + nonErrorException(report) + // simplify certain complex error messages (e.g. Ethjs) + simplifyErrorMessages(report) + // modify report urls + rewriteReportUrls(report) + } catch (err) { + console.warn(err) + } // make request normally client._makeRequest(opts) }, @@ -48,15 +42,42 @@ function setupRaven(opts) { return Raven } +function nonErrorException(report) { + // handle errors that lost their error-ness in serialization + if (report.message.includes('Non-Error exception captured with keys: message')) { + if (!(report.extra && report.extra.__serialized__)) return + report.message = `Non-Error Exception: ${report.extra.__serialized__.message}` + } +} + +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) { // 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) { |