diff options
author | HampusM <hampus@hampusmat.com> | 2021-07-21 22:00:04 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2021-07-21 22:00:04 +0200 |
commit | 7b9fca8d0061cf5e5af08cba98e9d5b6dbbed8ec (patch) | |
tree | 2a75dfaaa495c90e5519012e2c8e20ab0bd7ac4e /packages/server/src/git/blob.ts | |
parent | c0eb6635964de276b44851df67fb857ae94dc401 (diff) |
Began with better backend error handling & cleaned up the backend
Diffstat (limited to 'packages/server/src/git/blob.ts')
-rw-r--r-- | packages/server/src/git/blob.ts | 4 |
1 files changed, 4 insertions, 0 deletions
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<string> { + 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 |