/
home
/
infinitibizsol
/
autocrm.infinitibizsol.com
/
errors
/
File Upload :
llllll
Current File: /home/infinitibizsol/autocrm.infinitibizsol.com/errors/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({ status: 500, message: err.message }); } } 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 or token has expired.", }); } 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