From ddcf71225226bc0929d5c6d609b13ff0489e5b94 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 14 Aug 2021 22:28:17 +0200 Subject: Revamped backend error handling & improved imports in tests --- packages/server/src/git/repository.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packages/server/src/git/repository.ts') diff --git a/packages/server/src/git/repository.ts b/packages/server/src/git/repository.ts index 63ede23..9e83281 100644 --- a/packages/server/src/git/repository.ts +++ b/packages/server/src/git/repository.ts @@ -7,7 +7,7 @@ import { Commit } from "./commit"; import { FastifyReply } from "fastify"; import { Tag } from "./tag"; import { Tree } from "./tree"; -import { createError, RepositoryError } from "./error"; +import { createError, ErrorWhere, NotFoundError, UnknownError } from "./error"; /** * Returns the full name of a git repository @@ -162,15 +162,15 @@ export class Repository { public static async open(git_dir: string, repository: string, branch?: string): Promise { let ng_repository = await NodeGitRepository.openBare(`${git_dir}/${getFullRepositoryName(repository)}`).catch((err: WeirdError) => { if(err.errno === -3) { - throw(createError(RepositoryError, 404, "Repository not found")); + throw(createError(ErrorWhere.Repository, NotFoundError, "repository")); } - throw(createError(RepositoryError, 500, "Unknown error")); + throw(createError(ErrorWhere.Repository, UnknownError)); }); if(branch) { if(!await Branch.lookupExists(ng_repository, branch)) { - throw(createError(RepositoryError, 404, "Branch not found!")); + throw(createError(ErrorWhere.Repository, NotFoundError, "branch")); } } -- cgit v1.2.3-18-g5258