From 4b8e8e2634a5d5fbaecca51d8baa8e1c3e20ff59 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 25 Apr 2018 17:50:43 +0200 Subject: [PATCH 1/2] src: improve fatal exception This is just some code cleanup. --- src/node.cc | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/node.cc b/src/node.cc index 032963bff41a69..b1a93c7f622d30 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2388,15 +2388,12 @@ void FatalException(Isolate* isolate, Local fatal_exception_function = process_object->Get(fatal_exception_string).As(); - 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 @@ -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()) { ReportException(env, error, message); - exit_code = 1; + exit(1); } } - - if (exit_code) { - exit(exit_code); - } } From 4bfeabdb63767d88101d8c9f54a2b2f70ed49b0c Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 26 Apr 2018 03:31:51 +0200 Subject: [PATCH 2/2] fixup --- src/node.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node.cc b/src/node.cc index b1a93c7f622d30..e2d5337d120b93 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2389,7 +2389,7 @@ void FatalException(Isolate* isolate, process_object->Get(fatal_exception_string).As(); 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. ReportException(env, error, message); exit(6); @@ -2399,15 +2399,15 @@ void FatalException(Isolate* isolate, // Do not call FatalException when _fatalException handler throws 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 caught = fatal_exception_function->Call(process_object, 1, &error); 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); exit(7); - } else if (false == caught->BooleanValue()) { + } else if (caught->IsFalse()) { ReportException(env, error, message); exit(1); }