Answer the question
In order to leave comments, you need to log in
Global error handler for asynchronous errors?
Hello. Please tell me if it is possible to make a global middleware to catch asynchronous errors in Express.
Synchronized are excellent
routes.get('', (req, res) => { throw new Error('some-error'); }); // Эту ловит
app.use((err, req, res, next) => res.status(422).send(err.message));
routes.get('', async(req, res) => { throw new Error('some-error'); }); // Эту ловит
app.use((err, req, res, next) => res.status(422).send(err.message));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question