Skip to content
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
Next Next commit
src: improve fatal exception
This is just some code cleanup.
  • Loading branch information
BridgeAR committed Apr 25, 2018
commit 4b8e8e2634a5d5fbaecca51d8baa8e1c3e20ff59
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
Copy Markdown
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
Copy Markdown
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