mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-07 14:17:51 +02:00
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:
@@ -64,6 +64,13 @@ export class GitHubRepository {
|
|||||||
return commit.data;
|
return commit.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const status = (error as { status?: number }).status;
|
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) {
|
if (status === 404 || status === 422) {
|
||||||
// Distinguish: does the repo itself still exist?
|
// Distinguish: does the repo itself still exist?
|
||||||
let repoExists: boolean;
|
let repoExists: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user