src: improve fatal exception
This is just some code cleanup. PR-URL: https://github.com/nodejs/node/pull/20294 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
2b8512738a
commit
b87ef189e9
25
src/node.cc
25
src/node.cc
@ -2374,39 +2374,30 @@ void FatalException(Isolate* isolate,
|
|||||||
Local<Function> fatal_exception_function =
|
Local<Function> fatal_exception_function =
|
||||||
process_object->Get(fatal_exception_string).As<Function>();
|
process_object->Get(fatal_exception_string).As<Function>();
|
||||||
|
|
||||||
int exit_code = 0;
|
|
||||||
if (!fatal_exception_function->IsFunction()) {
|
if (!fatal_exception_function->IsFunction()) {
|
||||||
// failed before the process._fatalException function was added!
|
// Failed before the process._fatalException function was added!
|
||||||
// this is probably pretty bad. Nothing to do but report and exit.
|
// this is probably pretty bad. Nothing to do but report and exit.
|
||||||
ReportException(env, error, message);
|
ReportException(env, error, message);
|
||||||
exit_code = 6;
|
exit(6);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (exit_code == 0) {
|
|
||||||
TryCatch fatal_try_catch(isolate);
|
TryCatch fatal_try_catch(isolate);
|
||||||
|
|
||||||
// Do not call FatalException when _fatalException handler throws
|
// Do not call FatalException when _fatalException handler throws
|
||||||
fatal_try_catch.SetVerbose(false);
|
fatal_try_catch.SetVerbose(false);
|
||||||
|
|
||||||
// this will return true if the JS layer handled it, false otherwise
|
// This will return true if the JS layer handled it, false otherwise
|
||||||
Local<Value> caught =
|
Local<Value> caught =
|
||||||
fatal_exception_function->Call(process_object, 1, &error);
|
fatal_exception_function->Call(process_object, 1, &error);
|
||||||
|
|
||||||
if (fatal_try_catch.HasCaught()) {
|
if (fatal_try_catch.HasCaught()) {
|
||||||
// the fatal exception function threw, so we must exit
|
// The fatal exception function threw, so we must exit
|
||||||
ReportException(env, fatal_try_catch);
|
ReportException(env, fatal_try_catch);
|
||||||
exit_code = 7;
|
exit(7);
|
||||||
}
|
} else if (caught->IsFalse()) {
|
||||||
|
|
||||||
if (exit_code == 0 && false == caught->BooleanValue()) {
|
|
||||||
ReportException(env, error, message);
|
ReportException(env, error, message);
|
||||||
exit_code = 1;
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exit_code) {
|
|
||||||
exit(exit_code);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user