Skip to content
This repository was archived by the owner on Feb 22, 2025. It is now read-only.

Commit 69c158a

Browse files
committed
feat(error): ✨ Readd Error catching
1 parent 75b0c38 commit 69c158a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/web/routes/utils/Router.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Request, Response } from "express";
22

3+
import { ERROR_GENERIC } from "../../../util/Errors.js";
34
import Web from "../../Web.js";
45
import { Executor } from "./Executor.js";
56
import { RequestMethods } from "./RequestMethods.js";
@@ -25,7 +26,7 @@ export default class Router {
2526
.debug(
2627
`Registering endpoint "${requestMethod.toString()} api/${
2728
this.version
28-
}${endpoint}"`,
29+
}${endpoint}"`
2930
);
3031
this.web
3132
.getApp()
@@ -34,11 +35,21 @@ export default class Router {
3435
middlewares,
3536
(rq: Request, rs: Response, next: any) => {
3637
if (rq.method === requestMethod.valueOf()) {
37-
executor(rq, rs);
38+
try {
39+
executor(rq, rs);
40+
} catch (e) {
41+
ERROR_GENERIC(
42+
rq,
43+
rs,
44+
500,
45+
"Internal Server Error. Please try again and report this bug."
46+
);
47+
}
48+
3849
return;
3950
}
4051
next();
41-
},
52+
}
4253
);
4354
}
4455
}

0 commit comments

Comments
 (0)