error response nodejs code example
Example 1: error handling in node js
app.get('/', function (req, res, next) {
Promise.resolve().then(function () {
throw new Error('BROKEN')
}).catch(next) // Errors will be passed to Express.
})
Example 2: express generator error handling
app.get('/', function (req, res) {
throw new Error('BROKEN') // Express will catch this on its own.
})