aboutsummaryrefslogtreecommitdiff
path: root/src/config/errorHandler.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/config/errorHandler.ts')
-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;