Currently, in the Routes implementation, we have the following code as an example
serviceRouter.post('/', (req, res, next) => {
logger.info('Service post message received');
try {
post(req, res);
} catch (error) {
next(error);
}
});
The post function being called is usually an async function, therefore if an error occurs during its execution, we won't be able to catch those errors in the catch method as it is.
Therefore I suggest we modify the code to catch async errors like this
serviceRouter.post('/', async (req, res, next) => {
logger.info('Service post message received');
try {
await post(req, res);
} catch (error) {
next(error);
}
});
This change needs to be implemented for all connect applications and both for js and ts code.
Currently, in the Routes implementation, we have the following code as an example
The post function being called is usually an async function, therefore if an error occurs during its execution, we won't be able to catch those errors in the catch method as it is.
Therefore I suggest we modify the code to catch async errors like this
This change needs to be implemented for all connect applications and both for js and ts code.