SpaceNinjaServer/src/middleware/errorHandler.ts
Sainan 65a41ccc68
Some checks failed
Build / build (pull_request) Failing after 1m15s
fix: add try/catch around websocket message event handler
2025-07-21 16:40:42 +02:00

12 lines
424 B
TypeScript

import { NextFunction, Request, Response } from "express";
import { logError } from "@/src/utils/logger";
export const errorHandler = (err: Error, req: Request, res: Response, _next: NextFunction): void => {
if (err.message == "Invalid accountId-nonce pair") {
res.status(400).send("Log-in expired");
} else {
logError(err, `processing ${req.path} request`);
res.status(500).end();
}
};