Standardize error responses with consistent format and human-readable messages (#667)

This commit is contained in:
Thomas Durieux
2026-04-15 09:27:08 +02:00
committed by GitHub
parent f4209110c7
commit 8198a4b44a
10 changed files with 332 additions and 127 deletions
+3 -2
View File
@@ -114,7 +114,7 @@ export default class PullRequest {
this.status == "removing" ||
this.status == "removed"
) {
throw new AnonymousError("pullRequest_expired", {
throw new AnonymousError("pull_request_expired", {
object: this,
httpStatus: 410,
});
@@ -126,8 +126,9 @@ export default class PullRequest {
this.status == "preparing" ||
(this.status == "download" && this._model.statusDate > fiveMinuteAgo)
) {
throw new AnonymousError("pullRequest_not_ready", {
throw new AnonymousError("pull_request_not_ready", {
object: this,
httpStatus: 503,
});
}
}
+2
View File
@@ -220,6 +220,7 @@ export default class Repository {
) {
throw new AnonymousError("repository_not_ready", {
object: this,
httpStatus: 503,
});
}
}
@@ -356,6 +357,7 @@ export default class Repository {
await this.resetSate();
throw new AnonymousError("branch_not_found", {
object: this,
httpStatus: 404,
});
}
this._model.anonymizeDate = new Date();
+1 -1
View File
@@ -127,7 +127,7 @@ export default class S3Storage extends StorageBase {
}
} catch {
try {
res.status(500);
res.status(500).json({ error: "file_not_found" });
} catch (err) {
console.error(`[ERROR] S3 send ${path}`, err);
}