fix(auth): fix unnecessarly loud api errors

Summary:
Fixes T7520
Gets rid of the Gmail auth error too

Test Plan: manual

Reviewers: juan

Reviewed By: juan

Maniphest Tasks: T7520

Differential Revision: https://phab.nylas.com/D3688
This commit is contained in:
Evan Morikawa 2017-01-14 17:51:02 -08:00
parent 7210c80c5a
commit 231c510f86
2 changed files with 15 additions and 1 deletions

View file

@ -50,7 +50,15 @@ export async function makeGmailOAuthRequest(sessionKey, callback) {
auth: noauth,
},
});
const remoteJSON = await remoteRequest.run()
let remoteJSON = {}
try {
remoteJSON = await remoteRequest.run()
} catch (err) {
if (err.statusCode === 404) {
return
}
throw err
}
const localRequest = new NylasAPIRequest({
api: NylasAPI,
options: {

View file

@ -236,6 +236,12 @@ class AccountStore extends NylasStore {
const existing = this.accountForId(accountId)
if (!existing) return // user may have deleted
existing.fromJSON(json)
}).catch((err) => {
console.error(err);
// Dont't throw here. If this function gets run immediately at
// boot it may try before local-sync is ready. This is okay as
// we'll refresh the accounts later anyway. We'll also be
// eventually deprecating this API to merge it with K2
})
})).finally(() => {
this._caches = {}