import log from '../util/logger';

/* eslint-disable */
export function ErrorHandler1(err, req, res, next) {
  log.error(err);
  next(err);
}

export function ErrorHandler2(err, req, res, next) {
  err.status = err?.status ?? 'fail';
  err.statusCode = err?.statusCode ?? 500;

  res.status(err.statusCode).json({
    status: err.status,
    message: err.message,
    stack: process.env.NODE_ENV === 'development' ? err.stack : undefined,
  });
}
/* eslint-enable */
