process: inspect error in case of a fatal exception · nodejs/node@0393045 · GitHub
Skip to content

Commit 0393045

Browse files
BridgeARtargos
authored andcommitted
process: inspect error in case of a fatal exception
This makes sure that errors that shut down the application are inspected with `util.inspect()`. That makes sure that all extra properties on the error will be visible and also that the stack trace is highlighted (Node.js internal frames will be grey and node modules are underlined). PR-URL: #27243 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent ea62f4a commit 0393045

11 files changed

Lines changed: 76 additions & 9 deletions

lib/internal/process/execution.js

Lines changed: 6 additions & 1 deletion

test/message/assert_throws_stack.out

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,20 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
1515
at *
1616
at *
1717
at *
18-
at *
18+
at * {
19+
generatedMessage: true,
20+
code: 'ERR_ASSERTION',
21+
actual: Error: foo
22+
at assert.throws.bar (*assert_throws_stack.js:*)
23+
at getActual (assert.js:*)
24+
at Function.throws (assert.js:*)
25+
at Object.<anonymous> (*assert_throws_stack.js:*:*)
26+
at *
27+
at *
28+
at *
29+
at *
30+
at *
31+
at *,
32+
expected: [Object],
33+
operator: 'throws'
34+
}

test/message/error_exit.out

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,10 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
1313
at Module.load (internal/modules/cjs/loader.js:*:*)
1414
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
1515
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
16-
at internal/main/run_main_module.js:*:*
16+
at internal/main/run_main_module.js:*:* {
17+
generatedMessage: true,
18+
code: 'ERR_ASSERTION',
19+
actual: 1,
20+
expected: 2,
21+
operator: 'strictEqual'
22+
}

test/message/if-error-has-good-stack.out

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,20 @@ AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
1616
at Module.load (internal/modules/cjs/loader.js:*:*)
1717
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
1818
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
19-
at internal/main/run_main_module.js:*:*
19+
at internal/main/run_main_module.js:*:* {
20+
generatedMessage: false,
21+
code: 'ERR_ASSERTION',
22+
actual: Error: test error
23+
at c (*if-error-has-good-stack.js:*:*)
24+
at b (*if-error-has-good-stack.js:*:*)
25+
at a (*if-error-has-good-stack.js:*:*)
26+
at Object.<anonymous> (*if-error-has-good-stack.js:*:*)
27+
at Module._compile (internal/modules/cjs/loader.js:*:*)
28+
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
29+
at Module.load (internal/modules/cjs/loader.js:*:*)
30+
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
31+
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
32+
at internal/main/run_main_module.js:*:*
33+
expected: null,
34+
operator: 'ifError'
35+
}

test/message/stack_overflow.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ before
33
JSON.stringify(array);
44
^
55

6-
RangeError: Maximum call stack size exceeded
6+
[RangeError: Maximum call stack size exceeded]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
*test*message*throw_custom_error.js:*
22
throw ({ name: 'MyCustomError', message: 'This is a custom message' });
33
^
4-
MyCustomError: This is a custom message
4+
{ name: 'MyCustomError', message: 'This is a custom message' }

test/message/throw_in_line_with_tabs.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ before
22
*test*message*throw_in_line_with_tabs.js:*
33
throw ({ foo: 'bar' });
44
^
5-
[object Object]
5+
{ foo: 'bar' }

test/message/throw_non_error.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
*test*message*throw_non_error.js:*
22
throw ({ foo: 'bar' });
33
^
4-
[object Object]
4+
{ foo: 'bar' }

test/parallel/test-error-reporting.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ errExec('throws_error6.js', common.mustCall((err, stdout, stderr) => {
7777

7878
// Object that throws in toString() doesn't print garbage
7979
errExec('throws_error7.js', common.mustCall((err, stdout, stderr) => {
80-
assert.ok(/<toString\(\) threw exception/.test(stderr));
80+
assert.ok(/throw {\r?\n\^\r?\n{ toString: \[Function: toString] }\r?\n$/.test(stderr));
8181
}));
Lines changed: 10 additions & 0 deletions

0 commit comments

Comments
 (0)