2022-03-31 17:19:08 +00:00
|
|
|
function handleError(func) {
|
|
|
|
return (req, res) => {
|
2022-05-20 21:37:42 +00:00
|
|
|
func(req, res).catch((err) => {
|
|
|
|
console.log('Error', req.originalUrl, err);
|
2022-03-31 17:19:08 +00:00
|
|
|
res.status(500);
|
|
|
|
res.send({ status: 'error', reason: 'internal-error' });
|
|
|
|
});
|
|
|
|
};
|
2022-05-15 14:47:07 +00:00
|
|
|
}
|
2022-03-31 17:19:08 +00:00
|
|
|
|
2022-05-20 21:37:42 +00:00
|
|
|
module.exports = { handleError };
|