Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-12-28 17:36:26 +0300
committerRuben Bridgewater <ruben@bridgewater.de>2019-01-10 05:26:50 +0300
commitdfaa61fa18b5008912583ee8e00ebbd4f96debf6 (patch)
tree0e9b68d4b429e208e788d8dbe75f03c9601a1ea6 /lib/internal/assert.js
parent81b25eac21c15aa8fffda92f1501b9ffd593df5e (diff)
assert: make `actual` and `expected` getters
The `actual` and `expected` properties on an instance of `AssertionError` is now a getter to prevent inspecting these when inspecting the error. These values will be visible in the error message and showing them otherwise would decrease the readability of the error. PR-URL: https://github.com/nodejs/node/pull/25250 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/assert.js')
-rw-r--r--lib/internal/assert.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/internal/assert.js b/lib/internal/assert.js
index 29769fc5617..4e059db6b9d 100644
--- a/lib/internal/assert.js
+++ b/lib/internal/assert.js
@@ -395,6 +395,14 @@ class AssertionError extends Error {
this.operator = operator;
Error.captureStackTrace(this, stackStartFn);
}
+
+ [inspect.custom](recurseTimes, ctx) {
+ // This limits the `actual` and `expected` property default inspection to
+ // the minimum depth. Otherwise those values would be too verbose compared
+ // to the actual error message which contains a combined view of these two
+ // input values.
+ return inspect(this, { ...ctx, customInspect: false, depth: 0 });
+ }
}
module.exports = {