From 7b9fca8d0061cf5e5af08cba98e9d5b6dbbed8ec Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 21 Jul 2021 22:00:04 +0200 Subject: Began with better backend error handling & cleaned up the backend --- packages/server/src/git/blob.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'packages/server/src/git/blob.ts') diff --git a/packages/server/src/git/blob.ts b/packages/server/src/git/blob.ts index aeb1381..e44a979 100644 --- a/packages/server/src/git/blob.ts +++ b/packages/server/src/git/blob.ts @@ -1,4 +1,5 @@ import { TreeEntry as NodeGitTreeEntry } from "nodegit"; +import { BlobError, createError } from "./error"; export class Blob { private _ng_tree_entry: NodeGitTreeEntry; @@ -8,6 +9,9 @@ export class Blob { } public async content(): Promise { + if(!this._ng_tree_entry.isBlob()) { + throw(createError(BlobError, 500, "Not a blob")); + } return this._ng_tree_entry.isBlob() ? (await this._ng_tree_entry.getBlob()).toString() : ""; } } \ No newline at end of file -- cgit v1.2.3-18-g5258