Closed jasoncavanaugh closed 1 year ago
The backend is inconsistent in how it throws errors. In some cases, we throw errors like
res.status(statusCode); throw new Error("Some message");
In other cases, we have it do
throw { status: statusCode message: "Some message" }
We should be doing the former of these two. Additionally, errroMiddleware.ts should be checking for res.statusCode instead of err.status. Like this
errroMiddleware.ts
res.statusCode
err.status
export const errorHandler: ErrorRequestHandler = (err, req, res, next) => { const statusCode = res.statusCode || INTERNAL_SERVER_ERROR; res.status(statusCode); res.json({ message: err.message, stack: process.env.NODE_ENV === "production" ? null : err.stack, }); };
The backend is inconsistent in how it throws errors. In some cases, we throw errors like
In other cases, we have it do
We should be doing the former of these two. Additionally,
errroMiddleware.ts
should be checking forres.statusCode
instead oferr.status
. Like this