Merge pull request #1743 from transloadit/companion-errors

Companion errors
This commit is contained in:
Ifedapo .A. Olarewaju 2019-07-22 21:34:34 +01:00 committed by GitHub
commit bba0f70ba2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 11 deletions

View file

@ -30,8 +30,10 @@ module.exports = class Provider extends RequestClient {
onReceiveResponse (response) {
response = super.onReceiveResponse(response)
const authenticated = response.status !== 401
this.uppy.getPlugin(this.pluginId).setPluginState({ authenticated })
const plugin = this.uppy.getPlugin(this.pluginId)
const oldAuthenticated = plugin.getPluginState().authenticated
const authenticated = oldAuthenticated ? response.status !== 401 : response.status < 400
plugin.setPluginState({ authenticated })
return response
}

View file

@ -60,8 +60,8 @@ class Drive {
.where(where)
.auth(options.token)
.request((err, resp) => {
if (err) {
reject(err)
if (err || resp.statusCode !== 200) {
reject(this._error(err, resp))
return
}
resolve(resp)
@ -71,13 +71,6 @@ class Drive {
Promise.all([teamDrivesPromise, filesPromise])
.then(
([teamDrives, filesResponse]) => {
if (filesResponse.statusCode !== 200) {
const err = this._error(null, filesResponse)
logger.error(err, 'provider.drive.list.error')
done(err)
return
}
const returnData = this.adaptData(
filesResponse.body,
teamDrives && teamDrives.body,