diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-05-17 03:26:21 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-05-21 17:38:16 +0200 |
commit | e85228980278eb66da05110b154149a864c4cd1d (patch) | |
tree | 835d35bfb4a0bf3b965f7b18fdb85c341c086476 /lib/util.js | |
parent | 8de83725ac3aa05a12acbbd27012c4282af7635c (diff) | |
download | android-node-v8-e85228980278eb66da05110b154149a864c4cd1d.tar.gz android-node-v8-e85228980278eb66da05110b154149a864c4cd1d.tar.bz2 android-node-v8-e85228980278eb66da05110b154149a864c4cd1d.zip |
util: fix inspected stack indentation
Error stacks and multiline error messages were not correct indented.
This is fixed by this patch.
PR-URL: https://github.com/nodejs/node/pull/20802
Refs: https://github.com/nodejs/node/issues/20253
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'lib/util.js')
-rw-r--r-- | lib/util.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/util.js b/lib/util.js index 478d5c0442..10c48d804b 100644 --- a/lib/util.js +++ b/lib/util.js @@ -590,6 +590,11 @@ function formatValue(ctx, value, recurseTimes) { if (base.indexOf('\n at') === -1) { base = `[${base}]`; } + // The message and the stack have to be indented as well! + if (ctx.indentationLvl !== 0) { + const indentation = ' '.repeat(ctx.indentationLvl); + base = formatError(value).replace(/\n/g, `\n${indentation}`); + } if (keyLength === 0) return base; } else if (isAnyArrayBuffer(value)) { |