server/src/middleware/error.js
// Middleware that will help us catch generic express-related errors
Middleware that will help us catch generic express-related errors
Middleware that will help us catch generic express - related errors
function errorMiddleware(error, req, res, next) {
  if (res.headersSent) {
    next(error);
  } else {
    logger.error(error);
    res.status(error.statusCode || 500);
    res.json({
      message: error.message,
      ...(process.env.NODE_ENV === "production"
        ? null
        : { stack: error.stack }),
    });
  }
}
function errorMiddleware ( error , req , res , next ) { if ( res . headersSent ) { next ( error ) ; } else { logger . error ( error ) ; res . status ( error . statusCode || 500 ) ; res . json ( { message : error . message , ... ( process . env . NODE_ENV === "production" ? null : { stack : error . stack } ) , } ) ; } }
Middleware that will help us catch generic express-related errors
Middleware that will help us catch generic express - related errors