mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
assert: add compatibility for older Node.js versions
This makes sure the `AssertionError` still accepts the `stackStartFunction` option as alternative to the `stackStartFn`. PR-URL: https://github.com/nodejs/node/pull/27672 Fixes: https://github.com/nodejs/node/issues/27671 Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
2 files changed
+22
-2
No files matched your search
@@ -298,7 +298,9 @@ class AssertionError extends Error {
|
||||
const {
|
||||
message,
|
||||
operator,
|
||||
stackStartFn
|
||||
stackStartFn,
|
||||
// Compatibility with older versions.
|
||||
stackStartFunction
|
||||
} = options;
|
||||
let {
|
||||
actual,
|
||||
@@ -418,7 +420,7 @@ class AssertionError extends Error {
|
||||
this.expected = expected;
|
||||
this.operator = operator;
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
Error.captureStackTrace(this, stackStartFn);
|
||||
Error.captureStackTrace(this, stackStartFn || stackStartFunction);
|
||||
// Create error message including the error code in the name.
|
||||
this.stack;
|
||||
// Reset the name.
|
||||
|
||||
Reference in new issue
Block a user