Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: improve fatal exception #20294

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2388,15 +2388,12 @@ void FatalException(Isolate* isolate,
Local<Function> fatal_exception_function =
process_object->Get(fatal_exception_string).As<Function>();

int exit_code = 0;
if (!fatal_exception_function->IsFunction()) {
// failed before the process._fatalException function was added!
// this is probably pretty bad. Nothing to do but report and exit.
ReportException(env, error, message);
exit_code = 6;
}

if (exit_code == 0) {
exit(6);
} else {
TryCatch fatal_try_catch(isolate);

// Do not call FatalException when _fatalException handler throws
Expand All @@ -2409,18 +2406,12 @@ void FatalException(Isolate* isolate,
if (fatal_try_catch.HasCaught()) {
// the fatal exception function threw, so we must exit
ReportException(env, fatal_try_catch);
exit_code = 7;
}

if (exit_code == 0 && false == caught->BooleanValue()) {
exit(7);
} else if (false == caught->BooleanValue()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we either un-yoda-ize this and make it use the non-deprecated overload of BooleanValue, or switch to if (caught->IsFalse())?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed

ReportException(env, error, message);
exit_code = 1;
exit(1);
}
}

if (exit_code) {
exit(exit_code);
}
}


Expand Down