Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
Merge pull request #158 from taskcluster/stupid404
Browse files Browse the repository at this point in the history
Catch github auth error
  • Loading branch information
imbstack committed Feb 23, 2017
2 parents da23483 + a5b5a69 commit 2e513cc
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/api.js
Expand Up @@ -299,14 +299,20 @@ api.declare({
let ownerInfo = await this.OwnersDirectory.load({owner}, true);

if (ownerInfo) {
let instGithub = await this.github.getInstallationGithub(ownerInfo.installationId);
let reposList = await instGithub.integrations.getInstallationRepositories({});

// GitHub API returns an array of objects, each of wich has an array of repos
let installed = reposList.repositories.map(repo => repo.name).indexOf(repo);

res.reply({installed: installed != -1});
try {
let instGithub = await this.github.getInstallationGithub(ownerInfo.installationId);
let reposList = await instGithub.integrations.getInstallationRepositories({});

// GitHub API returns an array of objects, each of wich has an array of repos
let installed = reposList.repositories.map(repo => repo.name).indexOf(repo);

return res.reply({installed: installed != -1});
} catch (e) {
if (e.code > 400 && e.code < 500) {
return res.reply({installed: false});
}
throw e;
}
}

res.reply({installed: false});
return res.reply({installed: false});
});

0 comments on commit 2e513cc

Please sign in to comment.