Telemetry: handle undefined values (#851)
This commit is contained in:
@@ -126,7 +126,9 @@ function logUncaughtError (procName, e) {
|
|||||||
|
|
||||||
var message
|
var message
|
||||||
var stack = ''
|
var stack = ''
|
||||||
if (e.message) {
|
if (e == null) {
|
||||||
|
message = 'Unexpected undefined error'
|
||||||
|
} else if (e.message) {
|
||||||
// err is either an Error or a plain object {message, stack}
|
// err is either an Error or a plain object {message, stack}
|
||||||
message = e.message
|
message = e.message
|
||||||
stack = e.stack
|
stack = e.stack
|
||||||
@@ -149,11 +151,13 @@ function logUncaughtError (procName, e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof stack !== 'string') stack = 'Unexpected stack: ' + stack
|
||||||
|
if (typeof message !== 'string') message = 'Unexpected message: ' + message
|
||||||
|
|
||||||
// Remove the first part of each file path in the stack trace.
|
// Remove the first part of each file path in the stack trace.
|
||||||
// - Privacy: remove personal info like C:\Users\<full name>
|
// - Privacy: remove personal info like C:\Users\<full name>
|
||||||
// - Aggregation: this lets us find which stacktraces occur often
|
// - Aggregation: this lets us find which stacktraces occur often
|
||||||
if (stack && typeof stack === 'string') stack = stack.replace(/\(.*app.asar/g, '(...')
|
stack = stack.replace(/\(.*app.asar/g, '(...')
|
||||||
else if (stack) stack = 'Unexpected stack: ' + stack
|
|
||||||
|
|
||||||
// We need to POST the telemetry object, make sure it stays < 100kb
|
// We need to POST the telemetry object, make sure it stays < 100kb
|
||||||
if (telemetry.uncaughtErrors.length > 20) return
|
if (telemetry.uncaughtErrors.length > 20) return
|
||||||
|
|||||||
Reference in New Issue
Block a user