Stability: 1 - captureRejections is experimental.

    • err Error
    • eventName {string|symbol}
    • ...args {any}

    The Symbol.for('nodejs.rejection') method is called in case a promise rejection happens when emitting an event and [captureRejections][capturerejections] is enabled on the emitter. It is possible to use [events.captureRejectionSymbol][rejectionsymbol] in place of Symbol.for('nodejs.rejection').

    1. const { EventEmitter, captureRejectionSymbol } = require('events');
    2. class MyClass extends EventEmitter {
    3. constructor() {
    4. super({ captureRejections: true });
    5. }
    6. [captureRejectionSymbol](err, event, ...args) {
    7. console.log('rejection happened for', event, 'with', err, ...args);
    8. this.destroy(err);
    9. }
    10. destroy(err) {
    11. // Tear the resource down here.
    12. }
    13. }