Nodes VError package allows you add context to errors without losing the stack trace..catch(err => { throw new VError(err, "Trying to load config %s", filenamehere) })However, when logging errors for consuming by backend analytic systems (or platforms like datadog), the logs are often written out as JSON blobs on each line with a level, message, and all the other properties distinct as well. This allows you to quickly drill through similar errors without losing each errors context (who got this error? What was their state?) (https://github.com/winstonjs/winston){ level: 'warn', message: "Problem here", client:'X', cluster:'Y', foo: 'bar' }How can you both get added context to errors while also having JSON properties on error log lines? What is the proper way to handle errors in node?
Submitted October 02, 2019 at 07:22PM by Xeoncross
No comments:
Post a Comment