util: improve inspect by BridgeAR · Pull Request #20802 · nodejs/node · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 60 additions & 43 deletions lib/util.js
12 changes: 12 additions & 0 deletions test/message/util_inspect_error.js
Original file line number Diff line number Diff line change
@@ -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 }));
63 changes: 63 additions & 0 deletions test/message/util_inspect_error.out
Original file line number Diff line number Diff line change
@@ -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' }
2 changes: 1 addition & 1 deletion test/parallel/test-repl-underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function testError() {

// The error, both from the original throw and the `_error` echo.
'Error: foo',
'Error: foo',
'[Error: foo]',

// The sync error, with individual property echoes
/Error: ENOENT: no such file or directory, scandir '.*nonexistent.*'/,
Expand Down
16 changes: 8 additions & 8 deletions test/parallel/test-util-format.js
Loading