From cf4d3a99672cb4f0d0c2e1aba21903db3a278786 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Tue, 10 Sep 2024 16:41:40 +0700 Subject: [PATCH] chore: add more helper function --- src/utils/error.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/error.ts b/src/utils/error.ts index b55c8d3..ec62f5b 100644 --- a/src/utils/error.ts +++ b/src/utils/error.ts @@ -8,3 +8,11 @@ export function throwRelationError(name: string) { `relation${name.replaceAll(" ", "")}NotFound`, ); } + +export function throwNotFound(name: string) { + throw new HttpError( + HttpStatus.BAD_REQUEST, + `${name} cannot be found.`, + `${name.charAt(0).toLowerCase() + name.replaceAll(" ", "").slice(1)}NotFound`, + ); +}