MCPcopy Index your code
hub / github.com/nodejs/node / addCatch

Function addCatch

lib/events.js:356–376  ·  view source on GitHub ↗
(that, promise, type, args)

Source from the content-addressed store, hash-verified

354};
355
356function addCatch(that, promise, type, args) {
357 if (!that[kCapture]) {
358 return;
359 }
360
361 // Handle Promises/A+ spec, then could be a getter
362 // that throws on second use.
363 try {
364 const then = promise.then;
365
366 if (typeof then === 'function') {
367 then.call(promise, undefined, function(err) {
368 // The callback is called with nextTick to avoid a follow-up
369 // rejection from this promise.
370 process.nextTick(emitUnhandledRejectionOrErr, that, err, type, args);
371 });
372 }
373 } catch (err) {
374 that.emit('error', err);
375 }
376}
377
378function emitUnhandledRejectionOrErr(ee, err, type, args) {
379 if (typeof ee[kRejection] === 'function') {

Callers 1

events.jsFile · 0.70

Calls 2

callMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…