summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/internal/process/execution.js7
-rw-r--r--test/message/assert_throws_stack.out18
-rw-r--r--test/message/error_exit.out8
-rw-r--r--test/message/if-error-has-good-stack.out18
-rw-r--r--test/message/stack_overflow.out2
-rw-r--r--test/message/throw_custom_error.out2
-rw-r--r--test/message/throw_in_line_with_tabs.out2
-rw-r--r--test/message/throw_non_error.out2
-rw-r--r--test/parallel/test-error-reporting.js2
-rw-r--r--test/pseudo-tty/test-fatal-error.js10
-rw-r--r--test/pseudo-tty/test-fatal-error.out14
11 files changed, 76 insertions, 9 deletions
diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js
index 5eda7541c8..227c1c2149 100644
--- a/lib/internal/process/execution.js
+++ b/lib/internal/process/execution.js
@@ -142,8 +142,12 @@ function createFatalException() {
if (exceptionHandlerState.captureFn !== null) {
exceptionHandlerState.captureFn(er);
} else if (!process.emit('uncaughtException', er, type)) {
- // If someone handled it, then great. otherwise, die in C++ land
+ // If someone handled it, then great. Otherwise, die in C++ land
// since that means that we'll exit the process, emit the 'exit' event.
+ const { inspect } = require('internal/util/inspect');
+ const colors = internalBinding('util').guessHandleType(2) === 'TTY' &&
+ require('internal/tty').hasColors() ||
+ inspect.defaultOptions.colors;
try {
if (!process._exiting) {
process._exiting = true;
@@ -157,6 +161,7 @@ function createFatalException() {
const { kExpandStackSymbol } = require('internal/util');
if (typeof er[kExpandStackSymbol] === 'function')
er[kExpandStackSymbol]();
+ er.stack = inspect(er, { colors });
} catch {
// Nothing to be done about it at this point.
}
diff --git a/test/message/assert_throws_stack.out b/test/message/assert_throws_stack.out
index 7d4a7aecbc..e9f9cc5e89 100644
--- a/test/message/assert_throws_stack.out
+++ b/test/message/assert_throws_stack.out
@@ -15,4 +15,20 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
at *
at *
at *
- at *
+ at * {
+ generatedMessage: true,
+ code: 'ERR_ASSERTION',
+ actual: Error: foo
+ at assert.throws.bar (*assert_throws_stack.js:*)
+ at getActual (assert.js:*)
+ at Function.throws (assert.js:*)
+ at Object.<anonymous> (*assert_throws_stack.js:*:*)
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *,
+ expected: [Object],
+ operator: 'throws'
+}
diff --git a/test/message/error_exit.out b/test/message/error_exit.out
index b975d41a55..a0d848b125 100644
--- a/test/message/error_exit.out
+++ b/test/message/error_exit.out
@@ -13,4 +13,10 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
at Module.load (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
- at internal/main/run_main_module.js:*:*
+ at internal/main/run_main_module.js:*:* {
+ generatedMessage: true,
+ code: 'ERR_ASSERTION',
+ actual: 1,
+ expected: 2,
+ operator: 'strictEqual'
+}
diff --git a/test/message/if-error-has-good-stack.out b/test/message/if-error-has-good-stack.out
index c762d74aed..87261c451f 100644
--- a/test/message/if-error-has-good-stack.out
+++ b/test/message/if-error-has-good-stack.out
@@ -16,4 +16,20 @@ AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
at Module.load (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
- at internal/main/run_main_module.js:*:*
+ at internal/main/run_main_module.js:*:* {
+ generatedMessage: false,
+ code: 'ERR_ASSERTION',
+ actual: Error: test error
+ at c (*if-error-has-good-stack.js:*:*)
+ at b (*if-error-has-good-stack.js:*:*)
+ at a (*if-error-has-good-stack.js:*:*)
+ at Object.<anonymous> (*if-error-has-good-stack.js:*:*)
+ at Module._compile (internal/modules/cjs/loader.js:*:*)
+ at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
+ at Module.load (internal/modules/cjs/loader.js:*:*)
+ at Function.Module._load (internal/modules/cjs/loader.js:*:*)
+ at Function.Module.runMain (internal/modules/cjs/loader.js:*:*)
+ at internal/main/run_main_module.js:*:*
+ expected: null,
+ operator: 'ifError'
+}
diff --git a/test/message/stack_overflow.out b/test/message/stack_overflow.out
index c83f8001d9..d7a2c3eef0 100644
--- a/test/message/stack_overflow.out
+++ b/test/message/stack_overflow.out
@@ -3,4 +3,4 @@ before
JSON.stringify(array);
^
-RangeError: Maximum call stack size exceeded
+[RangeError: Maximum call stack size exceeded]
diff --git a/test/message/throw_custom_error.out b/test/message/throw_custom_error.out
index 0c6b9d128c..a1fa8c6c5b 100644
--- a/test/message/throw_custom_error.out
+++ b/test/message/throw_custom_error.out
@@ -1,4 +1,4 @@
*test*message*throw_custom_error.js:*
throw ({ name: 'MyCustomError', message: 'This is a custom message' });
^
-MyCustomError: This is a custom message
+{ name: 'MyCustomError', message: 'This is a custom message' }
diff --git a/test/message/throw_in_line_with_tabs.out b/test/message/throw_in_line_with_tabs.out
index 89a81beb41..9392ef5cca 100644
--- a/test/message/throw_in_line_with_tabs.out
+++ b/test/message/throw_in_line_with_tabs.out
@@ -2,4 +2,4 @@ before
*test*message*throw_in_line_with_tabs.js:*
throw ({ foo: 'bar' });
^
-[object Object]
+{ foo: 'bar' }
diff --git a/test/message/throw_non_error.out b/test/message/throw_non_error.out
index 2b7e0120b6..a744f786ca 100644
--- a/test/message/throw_non_error.out
+++ b/test/message/throw_non_error.out
@@ -1,4 +1,4 @@
*test*message*throw_non_error.js:*
throw ({ foo: 'bar' });
^
-[object Object]
+{ foo: 'bar' }
diff --git a/test/parallel/test-error-reporting.js b/test/parallel/test-error-reporting.js
index f56f1e4bdc..7568206d46 100644
--- a/test/parallel/test-error-reporting.js
+++ b/test/parallel/test-error-reporting.js
@@ -77,5 +77,5 @@ errExec('throws_error6.js', common.mustCall((err, stdout, stderr) => {
// Object that throws in toString() doesn't print garbage
errExec('throws_error7.js', common.mustCall((err, stdout, stderr) => {
- assert.ok(/<toString\(\) threw exception/.test(stderr));
+ assert.ok(/throw {\r?\n\^\r?\n{ toString: \[Function: toString] }\r?\n$/.test(stderr));
}));
diff --git a/test/pseudo-tty/test-fatal-error.js b/test/pseudo-tty/test-fatal-error.js
new file mode 100644
index 0000000000..3778ce035e
--- /dev/null
+++ b/test/pseudo-tty/test-fatal-error.js
@@ -0,0 +1,10 @@
+'use strict';
+require('../common');
+
+const { inspect } = require('util');
+
+inspect.defaultOptions.colors = true;
+
+const err = new TypeError('foobar');
+err.bla = true;
+throw err;
diff --git a/test/pseudo-tty/test-fatal-error.out b/test/pseudo-tty/test-fatal-error.out
new file mode 100644
index 0000000000..6114d7d9b0
--- /dev/null
+++ b/test/pseudo-tty/test-fatal-error.out
@@ -0,0 +1,14 @@
+*test-fatal-error.js:*
+throw err;
+^
+
+TypeError: foobar
+ at Object.<anonymous> (*test-fatal-error.js:*)
+*[90m at *(internal*loader.js:*:*)*[39m
+*[90m at *(internal*loader.js:*:*)*[39m
+*[90m at *(internal*loader.js:*:*)*[39m
+*[90m at *(internal*loader.js:*:*)*[39m
+*[90m at *[39m
+*[90m at *[39m {
+ bla: *[33mtrue*[39m
+}