aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRitesh Ghosh <[email protected]>2023-08-07 14:50:18 +0530
committerRitesh Ghosh <[email protected]>2023-08-07 14:50:18 +0530
commitc543ab83fbbe2c45a9065f75a80dd347aec79292 (patch)
tree2736a708f2789ed817f6cf4f4a7d3b32c881fef9 /src
parent53af5cbc253b318e28898c4be77b2580eb88c7b9 (diff)
downloadaniwatch-api-c543ab83fbbe2c45a9065f75a80dd347aec79292.tar.xz
aniwatch-api-c543ab83fbbe2c45a9065f75a80dd347aec79292.zip
refactor: added `errorHandler`
Diffstat (limited to 'src')
-rw-r--r--src/config/errorHandler.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/config/errorHandler.ts b/src/config/errorHandler.ts
new file mode 100644
index 0000000..e983f34
--- /dev/null
+++ b/src/config/errorHandler.ts
@@ -0,0 +1,11 @@
+import { ErrorRequestHandler } from "express";
+
+const errorHandler: ErrorRequestHandler = (error, req, res, next) => {
+ const status = error?.status || 500;
+ res.status(status).json({
+ status,
+ message: error?.message || "Something Went Wrong",
+ });
+};
+
+export default errorHandler;