fix: fix error message when repository is not found

This commit is contained in:
tdurieux
2023-02-22 09:57:49 +01:00
parent a558a6c2bd
commit f3b8860838
+8 -1
View File
@@ -55,6 +55,7 @@ export class GitHubRepository {
) { ) {
// get the list of repo from github // get the list of repo from github
const octokit = new Octokit({ auth: opt.accessToken }); const octokit = new Octokit({ auth: opt.accessToken });
try {
const branches = ( const branches = (
await octokit.paginate(octokit.repos.listBranches, { await octokit.paginate(octokit.repos.listBranches, {
owner: this.owner, owner: this.owner,
@@ -71,13 +72,19 @@ export class GitHubRepository {
} as Branch; } as Branch;
}); });
this._data.branches = branches; this._data.branches = branches;
if (isConnected) { if (isConnected) {
await RepositoryModel.updateOne( await RepositoryModel.updateOne(
{ externalId: this.id }, { externalId: this.id },
{ $set: { branches } } { $set: { branches } }
); );
} }
} catch (error) {
throw new AnonymousError("repo_not_found", {
httpStatus: (error as any).status,
cause: error as Error,
object: this,
});
}
} else if (isConnected) { } else if (isConnected) {
const q = await RepositoryModel.findOne({ externalId: this.id }).select( const q = await RepositoryModel.findOne({ externalId: this.id }).select(
"branches" "branches"