mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
src: consolidate exit codes in the code base
Add an ExitCode enum class and use it throughout the code base instead of hard-coding the exit codes everywhere. At the moment, the exit codes used in many places do not actually conform to what the documentation describes. With the new enums (which are also available to the JS land as constants in an internal binding) we could migrate to a more consistent usage of the codes, and eventually expose the constants to the user land when they are stable enough. PR-URL: https://github.com/nodejs/node/pull/44746 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
1 parent
66cedb4600
commit
be525d7d04
36 files changed
+381
-177
No files matched your search
@@ -45,6 +45,7 @@ using v8::HeapStatistics;
|
||||
using v8::Integer;
|
||||
using v8::Isolate;
|
||||
using v8::Local;
|
||||
using v8::Maybe;
|
||||
using v8::NewStringType;
|
||||
using v8::Number;
|
||||
using v8::Object;
|
||||
@@ -442,7 +443,11 @@ static void DebugEnd(const FunctionCallbackInfo<Value>& args) {
|
||||
static void ReallyExit(const FunctionCallbackInfo<Value>& args) {
|
||||
Environment* env = Environment::GetCurrent(args);
|
||||
RunAtExit(env);
|
||||
int code = args[0]->Int32Value(env->context()).FromMaybe(0);
|
||||
ExitCode code = ExitCode::kNoFailure;
|
||||
Maybe<int32_t> code_int = args[0]->Int32Value(env->context());
|
||||
if (!code_int.IsNothing()) {
|
||||
code = static_cast<ExitCode>(code_int.FromJust());
|
||||
}
|
||||
env->Exit(code);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user