From e85228980278eb66da05110b154149a864c4cd1d Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 17 May 2018 03:26:21 +0200 Subject: 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 Reviewed-By: James M Snell Reviewed-By: Matteo Collina Reviewed-By: Trivikram Kamat --- test/message/util_inspect_error.js | 12 +++++++ test/message/util_inspect_error.out | 63 +++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 test/message/util_inspect_error.js create mode 100644 test/message/util_inspect_error.out (limited to 'test/message') diff --git a/test/message/util_inspect_error.js b/test/message/util_inspect_error.js new file mode 100644 index 0000000000..20affd6c71 --- /dev/null +++ b/test/message/util_inspect_error.js @@ -0,0 +1,12 @@ +'use strict'; + +require('../common'); +const util = require('util'); + +const err = new Error('foo\nbar'); + +console.log(util.inspect({ err, nested: { err } }, { compact: true })); +console.log(util.inspect({ err, nested: { err } }, { compact: false })); + +err.foo = 'bar'; +console.log(util.inspect(err, { compact: true, breakLength: 5 })); diff --git a/test/message/util_inspect_error.out b/test/message/util_inspect_error.out new file mode 100644 index 0000000000..406d8112ce --- /dev/null +++ b/test/message/util_inspect_error.out @@ -0,0 +1,63 @@ +{ err: + Error: foo + bar + at *util_inspect_error* + at * + at * + at * + at * + at * + at * + at * + at * + nested: + { err: + Error: foo + bar + at *util_inspect_error* + at * + at * + at * + at * + at * + at * + at * + at * } } +{ + err: Error: foo + bar + at *util_inspect_error* + at * + at * + at * + at * + at * + at * + at * + at *, + nested: { + err: Error: foo + bar + at *util_inspect_error* + at * + at * + at * + at * + at * + at * + at * + at * + } +} +{ Error: foo +bar + at *util_inspect_error* + at * + at * + at * + at * + at * + at * + at * + at * + foo: 'bar' } -- cgit v1.2.3