diff options
author | HampusM <hampus@hampusmat.com> | 2021-08-14 22:28:17 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2021-08-14 22:28:17 +0200 |
commit | ddcf71225226bc0929d5c6d609b13ff0489e5b94 (patch) | |
tree | 7f788d29af4441e27d709aaec1359e205871a11b /packages/server/src/git/branch.ts | |
parent | 81b39ee7848b0fbdcd8b61a04077a58c23580dd1 (diff) |
Revamped backend error handling & improved imports in tests
Diffstat (limited to 'packages/server/src/git/branch.ts')
-rw-r--r-- | packages/server/src/git/branch.ts | 8 |
1 files changed, 4 insertions, 4 deletions
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<CommitSummary> { 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<Branch> { 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); } |