From f237a5f5a0db4da83b060aad27c527b2475fc54c Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sat, 14 Jan 2023 23:15:07 +0100 Subject: [PATCH] Created the error util --- src/utils/error.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/utils/error.ts diff --git a/src/utils/error.ts b/src/utils/error.ts new file mode 100644 index 0000000..076a457 --- /dev/null +++ b/src/utils/error.ts @@ -0,0 +1,4 @@ +import {Response} from "express"; + +export const sendError = (res: Response, httpCode: number, errorCode: number, message: string, fieldName?: string) => + res.status(httpCode).json({code: errorCode, message, fieldName}); \ No newline at end of file