Example #1
0
app.use((err, req, res, next) => {
  if (err instanceof SyntaxError && err.statusCode === 400) {
    logger.error('likely a bodyParser error', err.message, err.stack)
    res.status(400).json({ errors: ['invalid json'] })
  } else {
    next(err)
  }
})
Example #2
0
 client.on('error', (err) => {
   logger.error('redis client error', err.message, err.stack)
 })
Example #3
0
 cluster.on('exit', (worker) => {
   logger.error(`worker ${worker.process.pid} is down`)
   cluster.fork()
 })
Example #4
0
app.use((err, req, res, next) => {
  logger.error('catch-all error', err.message, err.stack)
  res.status(500).json({ errors: ['catch-all server error, check the logs'] })
})