From b87ef189e91e475ca4811addc3f4201641f8789b Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 25 Apr 2018 17:50:43 +0200 Subject: [PATCH] src: improve fatal exception This is just some code cleanup. PR-URL: https://github.com/nodejs/node/pull/20294 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- src/node.cc | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/node.cc b/src/node.cc index d8c0bded38da16..ee114257d5d126 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2374,39 +2374,30 @@ 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! + // 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 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_code = 7; - } - - if (exit_code == 0 && false == caught->BooleanValue()) { + exit(7); + } else if (caught->IsFalse()) { ReportException(env, error, message); - exit_code = 1; + exit(1); } } - - if (exit_code) { - exit(exit_code); - } }