Skip to content

Commit

Permalink
feat(error): ✨ Readd Error catching
Browse files Browse the repository at this point in the history
  • Loading branch information
Nudelsuppe42 committed Aug 22, 2024
1 parent 75b0c38 commit 69c158a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/web/routes/utils/Router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Request, Response } from "express";

import { ERROR_GENERIC } from "../../../util/Errors.js";
import Web from "../../Web.js";
import { Executor } from "./Executor.js";
import { RequestMethods } from "./RequestMethods.js";
Expand All @@ -25,7 +26,7 @@ export default class Router {
.debug(
`Registering endpoint "${requestMethod.toString()} api/${
this.version
}${endpoint}"`,
}${endpoint}"`
);
this.web
.getApp()
Expand All @@ -34,11 +35,21 @@ export default class Router {
middlewares,
(rq: Request, rs: Response, next: any) => {
if (rq.method === requestMethod.valueOf()) {
executor(rq, rs);
try {
executor(rq, rs);
} catch (e) {
ERROR_GENERIC(
rq,
rs,
500,
"Internal Server Error. Please try again and report this bug."
);
}

return;
}
next();
},
}
);
}
}

0 comments on commit 69c158a

Please sign in to comment.