Skip to content

Build your personal knowledge base with Trilium Notes

refactor(error_handlers): use existing NotFoundError class

Panagiotis Papadopoulos39d45dc11b23
diff --git a/src/routes/error_handlers.ts b/src/routes/error_handlers.ts
index e773fcb228..c570a9dbd0 100644
--- a/src/routes/error_handlers.ts
+++ b/src/routes/error_handlers.ts
@@ -1,5 +1,6 @@
import type { Application, NextFunction, Request, Response } from "express";
import log from "../services/log.js";
+import NotFoundError from "../errors/not_found_error.js";
function register(app: Application) {
app.use((err: any, req: Request, res: Response, next: NextFunction) => {
@@ -16,8 +17,7 @@ function register(app: Application) {
// catch 404 and forward to error handler
app.use((req, res, next) => {
- const err = new Error(`Router not found for request ${req.method} ${req.url}`);
- (err as any).status = 404;
+ const err = new NotFoundError(`Router not found for request ${req.method} ${req.url}`);
next(err);
});