Handle GitHub 409 "repository is empty" error in getCommitInfo

When a GitHub repo has no commits, the API returns 409 which was
unhandled, causing raw HttpError warnings. Now throws repo_empty
AnonymousError consistent with the existing convention.
This commit is contained in:
tdurieux
2026-05-07 07:42:05 +03:00
parent fbbc694747
commit 4ab8e0d1cd
+7
View File
@@ -64,6 +64,13 @@ export class GitHubRepository {
return commit.data;
} catch (error) {
const status = (error as { status?: number }).status;
if (status === 409) {
throw new AnonymousError("repo_empty", {
httpStatus: 409,
cause: error as Error,
object: this,
});
}
if (status === 404 || status === 422) {
// Distinguish: does the repo itself still exist?
let repoExists: boolean;