chore: improve error logging

This commit is contained in:
tdurieux
2022-08-10 08:12:50 +02:00
parent 1410a31577
commit 3497d315fa
9 changed files with 50 additions and 38 deletions

View File

@@ -17,11 +17,17 @@ export async function connect() {
}
export async function getRepository(repoId: string) {
if (!repoId) {
throw new AnonymousError("repo_not_found", {
object: repoId,
httpStatus: 404,
});
}
const data = await AnonymizedRepositoryModel.findOne({ repoId });
if (!data)
throw new AnonymousError("repo_not_found", {
object: repoId,
httpStatus: 400,
httpStatus: 404,
});
return new Repository(data);
}