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:
parent
5f3f8c85fc
commit
2a8d3ea450
@ -23,23 +23,14 @@ function setupRaven(opts) {
|
||||
release,
|
||||
transport: function(opts) {
|
||||
const report = opts.data
|
||||
// simplify certain complex error messages
|
||||
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
|
||||
})
|
||||
try {
|
||||
// simplify certain complex error messages (e.g. Ethjs)
|
||||
simplifyErrorMessages(report)
|
||||
// modify report urls
|
||||
rewriteReportUrls(report)
|
||||
} catch (err) {
|
||||
console.warn(err)
|
||||
}
|
||||
// modify report urls
|
||||
rewriteReportUrls(report)
|
||||
// make request normally
|
||||
client._makeRequest(opts)
|
||||
},
|
||||
@ -49,6 +40,23 @@ function setupRaven(opts) {
|
||||
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) {
|
||||
// update request url
|
||||
report.request.url = toMetamaskUrl(report.request.url)
|
||||
|
Loading…
Reference in New Issue
Block a user