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/branch.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packages/server/src/git/branch.ts') diff --git a/packages/server/src/git/branch.ts b/packages/server/src/git/branch.ts index 1dbb690..dacabda 100644 --- a/packages/server/src/git/branch.ts +++ b/packages/server/src/git/branch.ts @@ -2,7 +2,7 @@ import { CommitSummary } from "./commit"; import { Reference } from "./reference"; import { Repository } from "./repository"; import { Repository as NodeGitRepository } from "nodegit"; -import { BranchError, createError } from "./error"; +import { createError, ErrorWhere, FailedError, NotFoundError, UnknownError } from "./error"; /** * A representation of a branch @@ -17,7 +17,7 @@ export class Branch extends Reference { */ public async latestCommit(): Promise { const latest_commit = this._owner.ng_repository.getBranchCommit(this._ng_reference).catch(() => { - throw(createError(BranchError, 500, "Failed to get the latest commit")); + throw(createError(ErrorWhere.Branch, FailedError, "get the latest commit")); }); return { @@ -37,9 +37,9 @@ export class Branch extends Reference { public static async lookup(owner: Repository, branch: string): Promise { const reference = await owner.ng_repository.getBranch(branch).catch(err => { if(err.errno === -3) { - throw(createError(BranchError, 404, "Branch not found!")); + throw(createError(ErrorWhere.Branch, NotFoundError, "branch")); } - throw(createError(BranchError, 500, "Something went wrong.")); + throw(createError(ErrorWhere.Branch, UnknownError)); }); return new Branch(owner, reference); } -- cgit v1.2.3-18-g5258