mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 00:06:06 +08:00
fix(errors): Send 400 errors from the Nylas API to Sentry
This commit is contained in:
parent
53252fcb97
commit
94226ad9be
|
@ -272,10 +272,9 @@ class Atom extends Model
|
|||
|
||||
Promise.onPossiblyUnhandledRejection (error) =>
|
||||
error.stack = convertStackTrace(error.stack, sourceMapCache)
|
||||
eventObject = {message: error.message, originalError: error}
|
||||
|
||||
# API Errors are a normal part of life and are logged to the API
|
||||
# history panel. We ignore these errors and do not report them to Sentry.
|
||||
# API Errors are logged to Sentry only under certain circumstances,
|
||||
# and are logged directly from the NylasAPI class.
|
||||
if error instanceof APIError
|
||||
return
|
||||
|
||||
|
@ -289,9 +288,13 @@ class Atom extends Model
|
|||
console.warn(error)
|
||||
console.warn(error.stack)
|
||||
|
||||
@emitter.emit('will-throw-error', eventObject)
|
||||
@emit('uncaught-error', error.message, null, null, null, error)
|
||||
@emitter.emit('did-throw-error', eventObject)
|
||||
@emitError(error)
|
||||
|
||||
emitError: (error) ->
|
||||
eventObject = {message: error.message, originalError: error}
|
||||
@emitter.emit('will-throw-error', eventObject)
|
||||
@emit('uncaught-error', error.message, null, null, null, error)
|
||||
@emitter.emit('did-throw-error', eventObject)
|
||||
|
||||
###
|
||||
Section: Event Subscription
|
||||
|
|
|
@ -262,6 +262,16 @@ module.exports = ErrorReporter = (function() {
|
|||
ErrorReporter.prototype.reportError = function(err, metadata) {
|
||||
if (this.inSpecMode || this.inDevMode) { return };
|
||||
|
||||
// Never send user auth tokens
|
||||
if (err.requestOptions && err.requestOptions.auth) {
|
||||
delete err.requestOptions['auth'];
|
||||
}
|
||||
|
||||
// Never send message bodies
|
||||
if (err.requestOptions && err.requestOptions.body && err.requestOptions.body.body) {
|
||||
delete err.requestOptions.body['body'];
|
||||
}
|
||||
|
||||
this.client.captureError(err, {
|
||||
extra: metadata,
|
||||
tags: {
|
||||
|
|
|
@ -181,6 +181,8 @@ class NylasAPI
|
|||
handlePromise = @_handleModel404(options.url)
|
||||
if err.response.statusCode is 401
|
||||
handlePromise = @_handle401(options.url)
|
||||
if err.response.statusCode is 400
|
||||
atom.emitError(err)
|
||||
handlePromise.finally ->
|
||||
Promise.reject(err)
|
||||
|
||||
|
|
Loading…
Reference in a new issue