How to handle (i.e. log) change errors

In our application update, when we send an error message next, a general error of 500 is returned, and all this is normal. However, I also need to log the details of the error somewhere so that I know what happened.

I used to work on an express application, and the centralized error handling middleware gave us the ability to make any arbitrary code when receiving errors, such as logging.

What does “restore method” mean to centralize error logging? I do not want to open the application for registration in the entire application.

+4
source share
2 answers

A " " 'after', . 'after':

var svr = restify.createServer()
  .get('/hello-world', hello_world_hndlr)
  .on('after', function (req, resp, route, err) {
    // logging here
  })
  .listen(SVR_PORT)
+5

'after' 'restifyError':

server.on('restifyError', (req, res, err, cb) => {
  req.log.error(err)
  return cb();
});
+1

All Articles