Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-10-18 18:05:35 +0300
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-10-22 09:16:18 +0300
commit31217a8e88d7414579284267f8715112bf8a0fc6 (patch)
treed7add72e83fef8ea7779df087a8552c0ffc1748c /src/node_errors.cc
parent71b342f93725a9bba5fa1f83a9f0fa88a482d759 (diff)
cli: add --trace-uncaught flag
Add a flag that makes Node.js print the stack trace at the time of *throwing* uncaught exceptions, rather than at the creation of the `Error` object, if there is any. This is disabled by default because it affects GC behavior. PR-URL: https://github.com/nodejs/node/pull/30025 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'src/node_errors.cc')
-rw-r--r--src/node_errors.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/node_errors.cc b/src/node_errors.cc
index d3a409b1ab4..ec14746514e 100644
--- a/src/node_errors.cc
+++ b/src/node_errors.cc
@@ -380,6 +380,19 @@ static void ReportFatalException(Environment* env,
"%s\n%s: %s\n", *arrow_string, *name_string, *message_string);
}
}
+
+ if (!env->options()->trace_uncaught) {
+ PrintErrorString("(Use `node --trace-uncaught ...` to show "
+ "where the exception was thrown)\n");
+ }
+ }
+
+ if (env->options()->trace_uncaught) {
+ Local<StackTrace> trace = message->GetStackTrace();
+ if (!trace.IsEmpty()) {
+ PrintErrorString("Thrown at:\n");
+ PrintStackTrace(env->isolate(), trace);
+ }
}
fflush(stderr);