src: print error before aborting
In case of fatal errors, first print the error before aborting in case the process should abort on uncaught exceptions. PR-URL: https://github.com/nodejs/node/pull/26599 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
ffd2df063c
commit
2755471bf3
@ -14,10 +14,14 @@
|
||||
|
||||
namespace node {
|
||||
|
||||
using v8::Local;
|
||||
using v8::Message;
|
||||
using v8::Value;
|
||||
|
||||
enum ErrorHandlingMode { CONTEXTIFY_ERROR, FATAL_ERROR, MODULE_ERROR };
|
||||
void AppendExceptionLine(Environment* env,
|
||||
v8::Local<v8::Value> er,
|
||||
v8::Local<v8::Message> message,
|
||||
Local<Value> er,
|
||||
Local<Message> message,
|
||||
enum ErrorHandlingMode mode);
|
||||
|
||||
[[noreturn]] void FatalError(const char* location, const char* message);
|
||||
@ -27,9 +31,13 @@ void PrintErrorString(const char* format, ...);
|
||||
|
||||
void ReportException(Environment* env, const v8::TryCatch& try_catch);
|
||||
|
||||
void ReportException(Environment* env,
|
||||
Local<Value> er,
|
||||
Local<Message> message);
|
||||
|
||||
void FatalException(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> error,
|
||||
v8::Local<v8::Message> message);
|
||||
Local<Value> error,
|
||||
Local<Message> message);
|
||||
|
||||
// Helpers to construct errors similar to the ones provided by
|
||||
// lib/internal/errors.js.
|
||||
|
@ -110,11 +110,12 @@ static void SetPromiseRejectCallback(
|
||||
static void TriggerFatalException(const FunctionCallbackInfo<Value>& args) {
|
||||
Isolate* isolate = args.GetIsolate();
|
||||
Environment* env = Environment::GetCurrent(isolate);
|
||||
if (env != nullptr && env->abort_on_uncaught_exception()) {
|
||||
Abort();
|
||||
}
|
||||
Local<Value> exception = args[0];
|
||||
Local<Message> message = Exception::CreateMessage(isolate, exception);
|
||||
if (env != nullptr && env->abort_on_uncaught_exception()) {
|
||||
ReportException(env, exception, message);
|
||||
Abort();
|
||||
}
|
||||
FatalException(isolate, exception, message);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user