aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/git/repository.ts
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-08-14 22:28:17 +0200
committerHampusM <hampus@hampusmat.com>2021-08-14 22:28:17 +0200
commitddcf71225226bc0929d5c6d609b13ff0489e5b94 (patch)
tree7f788d29af4441e27d709aaec1359e205871a11b /packages/server/src/git/repository.ts
parent81b39ee7848b0fbdcd8b61a04077a58c23580dd1 (diff)
Revamped backend error handling & improved imports in tests
Diffstat (limited to 'packages/server/src/git/repository.ts')
-rw-r--r--packages/server/src/git/repository.ts8
1 files changed, 4 insertions, 4 deletions
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<Repository> {
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"));
}
}