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

Function getErrMessage

lib/internal/assert/utils.js:79–96  ·  view source on GitHub ↗

* Options consumed by innerFail to construct and throw the AssertionError. * @typedef {object} InnerFailOptions * @property {any} actual Actual value * @property {any} expected Expected value * @property {MessageTuple} message Message * @property {string} operator Operator * @property {Functio

(fn)

Source from the content-addressed store, hash-verified

77 */
78
79function getErrMessage(fn) {
80 const tmpLimit = Error.stackTraceLimit;
81 const errorStackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
82 // Make sure the limit is set to 1. Otherwise it could fail (<= 0) or it
83 // does to much work.
84 if (errorStackTraceLimitIsWritable) Error.stackTraceLimit = 1;
85 // We only need the stack trace. To minimize the overhead use an object
86 // instead of an error.
87 const err = {};
88 ErrorCaptureStackTrace(err, fn);
89 if (errorStackTraceLimitIsWritable) Error.stackTraceLimit = tmpLimit;
90
91 let source = getErrorSourceExpression(err);
92 if (source) {
93 source = StringPrototypeReplace(source, escapeSequencesRegExp, escapeFn);
94 return `The expression evaluated to a falsy value:\n\n ${source}\n`;
95 }
96}
97
98/**
99 * @param {InnerFailOptions} obj

Callers 1

innerOkFunction · 0.85

Calls 2

getErrorSourceExpressionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…