[client-app] Fix error when attempting to report a fetch id error

Summary:
When reporting error inside `IdentityStore._fetchIdentity`, we would
pass null as the `extra` parameter for `reportError`. This would cause
us to try to assign something to null and throw an error while reporting
the error.

(Even though `extra` has a default value of `{}` (see
declaration of `NylasEnv.reportError`), passing null will be interpreted
as a valid arg and it wont get assigned the default value)

Thankfully, the second error /is/ reported to sentry: https://sentry.io/nylas/nylas-mail/issues/230589717/

Test Plan: manual

Reviewers: mark, halla, spang, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4150
This commit is contained in:
Juan Tejada 2017-03-09 00:03:40 -08:00
parent 20a05d3340
commit 667e1d6691

View file

@ -184,7 +184,7 @@ class IdentityStore extends NylasStore {
const json = await this.fetchPath('/n1/user'); const json = await this.fetchPath('/n1/user');
if (!json || !json.id || json.id !== this._identity.id) { if (!json || !json.id || json.id !== this._identity.id) {
console.error(json) console.error(json)
NylasEnv.reportError(new Error("Remote Identity returned invalid json"), json) NylasEnv.reportError(new Error("Remote Identity returned invalid json"), json || {})
return Promise.resolve(this._identity) return Promise.resolve(this._identity)
} }
const nextIdentity = Object.assign({}, this._identity, json); const nextIdentity = Object.assign({}, this._identity, json);