mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-15 14:38:03 +02:00
Handle GitHub 422 errors as commit_not_found and sanitize error responses
This commit is contained in:
@@ -64,7 +64,7 @@ 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 === 404) {
|
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;
|
||||||
try {
|
try {
|
||||||
@@ -76,7 +76,7 @@ export class GitHubRepository {
|
|||||||
throw new AnonymousError(
|
throw new AnonymousError(
|
||||||
repoExists ? "commit_not_found" : "repo_not_found",
|
repoExists ? "commit_not_found" : "repo_not_found",
|
||||||
{
|
{
|
||||||
httpStatus: 404,
|
httpStatus: repoExists ? 422 : 404,
|
||||||
cause: error as Error,
|
cause: error as Error,
|
||||||
object: this,
|
object: this,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user