summaryrefslogtreecommitdiff
path: root/lib/internal/process
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-04-15 20:10:17 +0200
committerRuben Bridgewater <ruben@bridgewater.de>2019-05-16 12:50:05 +0200
commita9f518c901459e42afc76871dab9867967e9fa23 (patch)
tree039da3b7206947dec05cdf4fbe6ccdf809c98db3 /lib/internal/process
parentac2f2cd919ec549f908d3eb0b7fc8a6726a0ac25 (diff)
downloadandroid-node-v8-a9f518c901459e42afc76871dab9867967e9fa23.tar.gz
android-node-v8-a9f518c901459e42afc76871dab9867967e9fa23.tar.bz2
android-node-v8-a9f518c901459e42afc76871dab9867967e9fa23.zip
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: https://github.com/nodejs/node/pull/27243 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/internal/process')
-rw-r--r--lib/internal/process/execution.js7
1 files changed, 6 insertions, 1 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.
}