summaryrefslogtreecommitdiff
path: root/lib/internal
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-12-28 15:36:26 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2019-01-10 03:26:50 +0100
commitdfaa61fa18b5008912583ee8e00ebbd4f96debf6 (patch)
tree0e9b68d4b429e208e788d8dbe75f03c9601a1ea6 /lib/internal
parent81b25eac21c15aa8fffda92f1501b9ffd593df5e (diff)
downloadandroid-node-v8-dfaa61fa18b5008912583ee8e00ebbd4f96debf6.tar.gz
android-node-v8-dfaa61fa18b5008912583ee8e00ebbd4f96debf6.tar.bz2
android-node-v8-dfaa61fa18b5008912583ee8e00ebbd4f96debf6.zip
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')
-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 29769fc561..4e059db6b9 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 = {