/
home
/
infinitibizsol
/
.trash
/
errors.3
/
File Upload :
llllll
Current File: /home/infinitibizsol/.trash/errors.3/errorHandler.js
function errorHandler(err, req, res, next) { if (err.statusCode === 401) { res.status(401).json({ status: 401, message: err.message }); } else { res.status(500).json({ success: false, message: err }); } } function authenticationErrorHandler(err, req, res, next) { if (err.name === "UnauthorizedError") { // Authentication error for invalid token return res.status(401).json({ status: 401, errorMessage: "Authentication error: Invalid token.", }); } else if (err.name === "TokenExpiredError") { // Handle the token expiration error specifically return res .status(401) .json({ status: 401, message: "Token has expired. Please login again." }); } // Forward any other errors we're not explicitly handling to the default error handler next(err); } module.exports = { errorHandler, authenticationErrorHandler };
Copyright ©2k19 -
Hexid
|
Tex7ure