fix: Expose error stack together with error message
This commit is contained in:
@@ -4,11 +4,16 @@ import logger from './logger';
|
|||||||
import BaseError from '../errors/base';
|
import BaseError from '../errors/base';
|
||||||
|
|
||||||
// Do not remove `next` argument as the function signature will not fit for an error handler middleware
|
// Do not remove `next` argument as the function signature will not fit for an error handler middleware
|
||||||
const errorHandler = (err: BaseError, req: Request, res: Response, next: NextFunction): void => {
|
const errorHandler = (
|
||||||
|
err: BaseError,
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): void => {
|
||||||
if (err.message === 'Not Found') {
|
if (err.message === 'Not Found') {
|
||||||
res.status(404).end();
|
res.status(404).end();
|
||||||
} else {
|
} else {
|
||||||
logger.error(err.message);
|
logger.error(err.message + '\n' + err.stack);
|
||||||
res.status(err.statusCode || 500).send(err.message);
|
res.status(err.statusCode || 500).send(err.message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user