MCPcopy Create free account
hub / github.com/nodejs/node / throwUnhandledRejectionsMode

Function throwUnhandledRejectionsMode

lib/internal/process/promises.js:316–328  ·  view source on GitHub ↗

* --unhandled-rejections=throw: * Emit 'unhandledRejection', if it's unhandled, emit * 'uncaughtException'. If it's not handled, print the error to stderr * and exit the process. * @type {UnhandledRejectionsModeHandler}

(promise, promiseInfo)

Source from the content-addressed store, hash-verified

314 * @type {UnhandledRejectionsModeHandler}
315 */
316function throwUnhandledRejectionsMode(promise, promiseInfo) {
317 const reason = promiseInfo.reason;
318 const handled = emitUnhandledRejection(promise, promiseInfo);
319 if (!handled) {
320 const err = isErrorLike(reason) ?
321 reason :
322 new UnhandledPromiseRejection(reason);
323 // This destroys the async stack, don't clear it after
324 triggerUncaughtException(err, true /* fromPromise */);
325 return false;
326 }
327 return true;
328}
329
330/**
331 * --unhandled-rejections=warn-with-error-code:

Callers

nothing calls this directly

Calls 2

emitUnhandledRejectionFunction · 0.85
isErrorLikeFunction · 0.70

Tested by

no test coverage detected