mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
src: mark fatal error functions as noreturn
OnFatalError and OOMErrorHandler will not return control flow to the calling function. node::FatalError is an alias of node::OnFatalError. Replace all the callsites with node::OnFatalError instead. PR-URL: https://github.com/nodejs/node/pull/47695 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
This commit is contained in:
1 parent
d3449ca010
commit
8e6af9fcf4
7 files changed
+12
-19
No files matched your search
@@ -661,8 +661,7 @@ Maybe<bool> InitializeContextRuntime(Local<Context> context) {
|
||||
}
|
||||
} else if (per_process::cli_options->disable_proto != "") {
|
||||
// Validated in ProcessGlobalArgs
|
||||
FatalError("InitializeContextRuntime()",
|
||||
"invalid --disable-proto mode");
|
||||
OnFatalError("InitializeContextRuntime()", "invalid --disable-proto mode");
|
||||
}
|
||||
|
||||
return Just(true);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace node {
|
||||
namespace inspector {
|
||||
namespace {
|
||||
|
||||
using node::FatalError;
|
||||
using node::OnFatalError;
|
||||
|
||||
using v8::Context;
|
||||
using v8::Function;
|
||||
@@ -898,8 +898,8 @@ void Agent::ToggleAsyncHook(Isolate* isolate, Local<Function> fn) {
|
||||
USE(fn->Call(context, Undefined(isolate), 0, nullptr));
|
||||
if (try_catch.HasCaught() && !try_catch.HasTerminated()) {
|
||||
PrintCaughtException(isolate, context, try_catch);
|
||||
FatalError("\nnode::inspector::Agent::ToggleAsyncHook",
|
||||
"Cannot toggle Inspector's AsyncHook, please report this.");
|
||||
OnFatalError("\nnode::inspector::Agent::ToggleAsyncHook",
|
||||
"Cannot toggle Inspector's AsyncHook, please report this.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -645,7 +645,8 @@ NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
|
||||
NODE_EXTERN IsolateData* GetEnvironmentIsolateData(Environment* env);
|
||||
NODE_EXTERN ArrayBufferAllocator* GetArrayBufferAllocator(IsolateData* data);
|
||||
|
||||
NODE_EXTERN void OnFatalError(const char* location, const char* message);
|
||||
[[noreturn]] NODE_EXTERN void OnFatalError(const char* location,
|
||||
const char* message);
|
||||
NODE_EXTERN void PromiseRejectCallback(v8::PromiseRejectMessage message);
|
||||
NODE_EXTERN bool AllowWasmCodeGenerationCallback(v8::Local<v8::Context> context,
|
||||
v8::Local<v8::String>);
|
||||
|
||||
+1
-1
@@ -805,7 +805,7 @@ NAPI_NO_RETURN void NAPI_CDECL napi_fatal_error(const char* location,
|
||||
message_string.assign(const_cast<char*>(message), strlen(message));
|
||||
}
|
||||
|
||||
node::FatalError(location_string.c_str(), message_string.c_str());
|
||||
node::OnFatalError(location_string.c_str(), message_string.c_str());
|
||||
}
|
||||
|
||||
napi_status NAPI_CDECL
|
||||
|
||||
+2
-8
@@ -499,13 +499,7 @@ static void ReportFatalException(Environment* env,
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
[[noreturn]] void FatalError(const char* location, const char* message) {
|
||||
OnFatalError(location, message);
|
||||
// to suppress compiler warning
|
||||
ABORT();
|
||||
}
|
||||
|
||||
void OnFatalError(const char* location, const char* message) {
|
||||
[[noreturn]] void OnFatalError(const char* location, const char* message) {
|
||||
if (location) {
|
||||
FPrintF(stderr, "FATAL ERROR: %s %s\n", location, message);
|
||||
} else {
|
||||
@@ -527,7 +521,7 @@ void OnFatalError(const char* location, const char* message) {
|
||||
ABORT();
|
||||
}
|
||||
|
||||
void OOMErrorHandler(const char* location, bool is_heap_oom) {
|
||||
[[noreturn]] void OOMErrorHandler(const char* location, bool is_heap_oom) {
|
||||
const char* message =
|
||||
is_heap_oom ? "Allocation failed - JavaScript heap out of memory"
|
||||
: "Allocation failed - process out of memory";
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ void AppendExceptionLine(Environment* env,
|
||||
enum ErrorHandlingMode mode);
|
||||
|
||||
[[noreturn]] void FatalError(const char* location, const char* message);
|
||||
void OnFatalError(const char* location, const char* message);
|
||||
void OOMErrorHandler(const char* location, bool is_heap_oom);
|
||||
[[noreturn]] void OnFatalError(const char* location, const char* message);
|
||||
[[noreturn]] void OOMErrorHandler(const char* location, bool is_heap_oom);
|
||||
|
||||
// Helpers to construct errors similar to the ones provided by
|
||||
// lib/internal/errors.js.
|
||||
|
||||
@@ -45,8 +45,7 @@ Watchdog::Watchdog(v8::Isolate* isolate, uint64_t ms, bool* timed_out)
|
||||
int rc;
|
||||
rc = uv_loop_init(&loop_);
|
||||
if (rc != 0) {
|
||||
FatalError("node::Watchdog::Watchdog()",
|
||||
"Failed to initialize uv loop.");
|
||||
OnFatalError("node::Watchdog::Watchdog()", "Failed to initialize uv loop.");
|
||||
}
|
||||
|
||||
rc = uv_async_init(&loop_, &async_, [](uv_async_t* signal) {
|
||||
|
||||
Reference in new issue
Block a user