feat: improve error message

This commit is contained in:
tdurieux
2021-09-06 22:34:58 +02:00
parent 36c1098d55
commit eaa9656815
16 changed files with 147 additions and 72 deletions

View File

@@ -2,6 +2,7 @@ import * as mongoose from "mongoose";
import Repository from "../Repository";
import config from "../../config";
import AnonymizedRepositoryModel from "./anonymizedRepositories/anonymizedRepositories.model";
import AnonymousError from "../AnonymousError";
const MONGO_URL = `mongodb://${config.DB_USERNAME}:${config.DB_PASSWORD}@${config.DB_HOSTNAME}:27017/`;
@@ -23,6 +24,6 @@ export async function connect() {
export async function getRepository(repoId: string) {
const data = await AnonymizedRepositoryModel.findOne({ repoId });
if (!data) throw new Error("repo_not_found");
if (!data) throw new AnonymousError("repo_not_found", repoId);
return new Repository(data);
}