Skip to content

process: add optional detail to process emitWarning

Adds a new method signature variant for process.emitWarning() that accepts an options object. The options object may include a new detail option that allows additional detail text to be associated with the warning. By default, this additional text will be printed to stderr along with the warning, and included on the Warning Error object using the .detail property.

e.g.

process.emitWarning('A message', {
  code: 'WARNING123',
  detail: 'This is additional detail'
});
// Emits:
// (node {pid}) [WARNING123] Warning: A message
// This is additional detail

The primary use case for this is to allow additional information, such as links to Node.js documentation, expanded explanations, etc, to be included with the warning.

/cc @cjihrig @sam-github

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

process

Merge request reports

Loading