Skip to content

Commit e0d2bc5

Browse files
BridgeARMylesBorins
authored andcommitted
src: improve fatal exception
This is just some code cleanup. PR-URL: #20294 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 2ce4b7c commit e0d2bc5

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/node.cc

+8-17
Original file line numberDiff line numberDiff line change
@@ -2388,39 +2388,30 @@ void FatalException(Isolate* isolate,
23882388
Local<Function> fatal_exception_function =
23892389
process_object->Get(fatal_exception_string).As<Function>();
23902390

2391-
int exit_code = 0;
23922391
if (!fatal_exception_function->IsFunction()) {
2393-
// failed before the process._fatalException function was added!
2392+
// Failed before the process._fatalException function was added!
23942393
// this is probably pretty bad. Nothing to do but report and exit.
23952394
ReportException(env, error, message);
2396-
exit_code = 6;
2397-
}
2398-
2399-
if (exit_code == 0) {
2395+
exit(6);
2396+
} else {
24002397
TryCatch fatal_try_catch(isolate);
24012398

24022399
// Do not call FatalException when _fatalException handler throws
24032400
fatal_try_catch.SetVerbose(false);
24042401

2405-
// this will return true if the JS layer handled it, false otherwise
2402+
// This will return true if the JS layer handled it, false otherwise
24062403
Local<Value> caught =
24072404
fatal_exception_function->Call(process_object, 1, &error);
24082405

24092406
if (fatal_try_catch.HasCaught()) {
2410-
// the fatal exception function threw, so we must exit
2407+
// The fatal exception function threw, so we must exit
24112408
ReportException(env, fatal_try_catch);
2412-
exit_code = 7;
2413-
}
2414-
2415-
if (exit_code == 0 && false == caught->BooleanValue()) {
2409+
exit(7);
2410+
} else if (caught->IsFalse()) {
24162411
ReportException(env, error, message);
2417-
exit_code = 1;
2412+
exit(1);
24182413
}
24192414
}
2420-
2421-
if (exit_code) {
2422-
exit(exit_code);
2423-
}
24242415
}
24252416

24262417

0 commit comments

Comments
 (0)