not sure why those errors got removed we'll see

This commit is contained in:
2025-12-26 08:59:31 -08:00
parent 91fa2f0516
commit ed3af07aab
2 changed files with 7 additions and 3 deletions

View File

@@ -63,7 +63,11 @@ export const errorHandler = (err: Error, req: Request, res: Response, next: Next
}
// --- Handle Generic Client Errors (e.g., from express-jwt, or manual status setting) ---
const status = (err as any).status || (err as any).statusCode;
let status = (err as any).status || (err as any).statusCode;
// Default UnauthorizedError to 401 if no status is present, a common case for express-jwt.
if (err.name === 'UnauthorizedError' && !status) {
status = 401;
}
if (status && status >= 400 && status < 500) {
log.warn({ err, statusCode: status }, `Client Error on ${req.method} ${req.path}: ${err.message}`);
return res.status(status).json({ message: err.message });