fix: error handler

This commit is contained in:
Bobby 2023-09-06 19:00:42 +07:00
parent 3d9c400cab
commit c905728c70
No known key found for this signature in database
GPG Key ID: B2F45B6A3C9A8FCA

View File

@ -13,8 +13,8 @@ const self = {
self.handleError = (req, res, error) => { self.handleError = (req, res, error) => {
if (!res || res.headersSent) { if (!res || res.headersSent) {
logger.error('Error: Unexpected missing "res" object or headers alredy sent.') logger.error(error)
return logger.error(error) return
} }
res.header('Cache-Control', 'no-store') res.header('Cache-Control', 'no-store')
@ -62,6 +62,8 @@ self.handleError = (req, res, error) => {
} }
self.handleNotFound = (req, res) => { self.handleNotFound = (req, res) => {
if (!res || res.headersSent) return
res.header('Cache-Control', 'no-store') res.header('Cache-Control', 'no-store')
return res return res
.status(404) .status(404)