diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-05-17 04:54:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-17 04:54:15 +0800 |
commit | 76c8cb3d7b1cbd5b5a3e48fac4b08e44ad936850 (patch) | |
tree | fd67668ef48f8fd86bcd3acd1b2a4dca5aca189e /app | |
parent | 4be681f44722c6ca678b48cb009700a7d775aa2a (diff) | |
parent | 93a9ef284e527a4a7d26305be8abf455d938cca4 (diff) | |
download | tangerine-wallet-browser-76c8cb3d7b1cbd5b5a3e48fac4b08e44ad936850.tar tangerine-wallet-browser-76c8cb3d7b1cbd5b5a3e48fac4b08e44ad936850.tar.gz tangerine-wallet-browser-76c8cb3d7b1cbd5b5a3e48fac4b08e44ad936850.tar.bz2 tangerine-wallet-browser-76c8cb3d7b1cbd5b5a3e48fac4b08e44ad936850.tar.lz tangerine-wallet-browser-76c8cb3d7b1cbd5b5a3e48fac4b08e44ad936850.tar.xz tangerine-wallet-browser-76c8cb3d7b1cbd5b5a3e48fac4b08e44ad936850.tar.zst tangerine-wallet-browser-76c8cb3d7b1cbd5b5a3e48fac4b08e44ad936850.zip |
Merge pull request #4146 from MetaMask/sentry-error-like2
sentry - add helper to fully rewrite all error messages
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/lib/setupRaven.js | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/app/scripts/lib/setupRaven.js b/app/scripts/lib/setupRaven.js index b1b67f771..d164827ab 100644 --- a/app/scripts/lib/setupRaven.js +++ b/app/scripts/lib/setupRaven.js @@ -25,7 +25,7 @@ function setupRaven(opts) { const report = opts.data try { // handle error-like non-error exceptions - nonErrorException(report) + rewriteErrorLikeExceptions(report) // simplify certain complex error messages (e.g. Ethjs) simplifyErrorMessages(report) // modify report urls @@ -42,27 +42,35 @@ 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 rewriteErrorLikeExceptions(report) { + // handle errors that lost their error-ness in serialization (e.g. dnode) + rewriteErrorMessages(report, (errorMessage) => { + if (!errorMessage.includes('Non-Error exception captured with keys:')) return errorMessage + if (!(report.extra && report.extra.__serialized__ && report.extra.__serialized__.message)) return errorMessage + return `Non-Error Exception: ${report.extra.__serialized__.message}` + }) } function simplifyErrorMessages(report) { + rewriteErrorMessages(report, (errorMessage) => { + // 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' + } + return errorMessage + }) +} + +function rewriteErrorMessages(report, rewriteFn) { + // rewrite top level message + report.message = rewriteFn(report.message) + // rewrite each exception message 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 + item.value = rewriteFn(item.value) }) } } |