Skip to content

Commit 6ce0656

Browse files
committed
fixup! util: fix error catch indentation
1 parent 10d997d commit 6ce0656

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

lib/internal/util/inspect.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,9 +2544,9 @@ function formatProperty(ctx, value, recurseTimes, key, type, desc,
25442544
if (ctx.getters && (ctx.getters === true ||
25452545
(ctx.getters === 'get' && desc.set === undefined) ||
25462546
(ctx.getters === 'set' && desc.set !== undefined))) {
2547+
ctx.indentationLvl += 2;
25472548
try {
25482549
const tmp = FunctionPrototypeCall(desc.get, original);
2549-
ctx.indentationLvl += 2;
25502550
if (tmp === null) {
25512551
str = `${s(`[${label}:`, sp)} ${s('null', 'null')}${s(']', sp)}`;
25522552
} else if (typeof tmp === 'object') {
@@ -2555,13 +2555,11 @@ function formatProperty(ctx, value, recurseTimes, key, type, desc,
25552555
const primitive = formatPrimitive(s, tmp, ctx);
25562556
str = `${s(`[${label}:`, sp)} ${primitive}${s(']', sp)}`;
25572557
}
2558-
ctx.indentationLvl -= 2;
25592558
} catch (err) {
2560-
ctx.indentationLvl += 2;
25612559
const message = `<Inspection threw (${formatValue(ctx, err, recurseTimes)})>`;
2562-
ctx.indentationLvl -= 2;
25632560
str = `${s(`[${label}:`, sp)} ${message}${s(']', sp)}`;
25642561
}
2562+
ctx.indentationLvl -= 2;
25652563
} else {
25662564
str = ctx.stylize(`[${label}]`, sp);
25672565
}

test/parallel/test-util-inspect.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3481,21 +3481,21 @@ assert.strictEqual(
34813481
inspect(Object.getPrototypeOf(bar), { showHidden: true, getters: true }),
34823482
new RegExp('^' + RegExp.escape(
34833483
'<ref *1> Foo [Map] {\n' +
3484-
' [constructor]: [class Bar extends Foo] {\n' +
3485-
' [length]: 0,\n' +
3486-
" [name]: 'Bar',\n" +
3487-
' [prototype]: [Circular *1],\n' +
3488-
' [Symbol(Symbol.species)]: [Getter: <Inspection threw ' +
3484+
' [constructor]: [class Bar extends Foo] {\n' +
3485+
' [length]: 0,\n' +
3486+
" [name]: 'Bar',\n" +
3487+
' [prototype]: [Circular *1],\n' +
3488+
' [Symbol(Symbol.species)]: [Getter: <Inspection threw ' +
34893489
"(TypeError: Symbol.prototype.toString requires that 'this' be a Symbol") + '.*' + RegExp.escape(')>]\n' +
3490-
' },\n' +
3491-
" [xyz]: [Getter: 'YES!'],\n" +
3492-
' [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]] {\n' +
3493-
' [length]: 0,\n' +
3494-
" [name]: '[nodejs.util.inspect.custom]'\n" +
3495-
' },\n' +
3496-
' [abc]: [Getter: true],\n' +
3497-
' [def]: [Getter/Setter: false]\n' +
3498-
' }'
3490+
' },\n' +
3491+
" [xyz]: [Getter: 'YES!'],\n" +
3492+
' [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]] {\n' +
3493+
' [length]: 0,\n' +
3494+
" [name]: '[nodejs.util.inspect.custom]'\n" +
3495+
' },\n' +
3496+
' [abc]: [Getter: true],\n' +
3497+
' [def]: [Getter/Setter: false]\n' +
3498+
'}'
34993499
) + '$', 's')
35003500
);
35013501

0 commit comments

Comments
 (0)