diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-10-18 18:05:35 +0300 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2019-10-22 09:16:18 +0300 |
commit | 31217a8e88d7414579284267f8715112bf8a0fc6 (patch) | |
tree | d7add72e83fef8ea7779df087a8552c0ffc1748c /src/node_errors.cc | |
parent | 71b342f93725a9bba5fa1f83a9f0fa88a482d759 (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.cc | 13 |
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); |