Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e0d2bc5

Browse filesBrowse files
BridgeARMylesBorins
authored andcommitted
src: improve fatal exception
This is just some code cleanup. PR-URL: #20294 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 2ce4b7c commit e0d2bc5
Copy full SHA for e0d2bc5

File tree

Expand file treeCollapse file tree

1 file changed

+8
-17
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-17
lines changed
Open diff view settings
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+8-17Lines changed: 8 additions & 17 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.