feat: Catch not found error message for objection
This commit is contained in:
@@ -2,12 +2,12 @@ import logger from './logger.js';
|
||||
|
||||
// Do not remove `next` argument as the function signature will not fit for an error handler middleware
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const errorHandler = (err, req, res, next) => {
|
||||
if (err.message === 'Not Found') {
|
||||
res.status(404).end();
|
||||
const errorHandler = (error, request, response, next) => {
|
||||
if (error.message === 'Not Found' || error.message === 'NotFoundError') {
|
||||
response.status(404).end();
|
||||
} else {
|
||||
logger.error(err.message + '\n' + err.stack);
|
||||
res.status(err.statusCode || 500).send(err.message);
|
||||
logger.error(error.message + '\n' + error.stack);
|
||||
response.status(error.statusCode || 500).send(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user