Skip to content

Commit

Permalink
src: create THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed Feb 19, 2025
1 parent 646be93 commit 16aff57
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
10 changes: 10 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,16 @@ added: v15.0.0
An operation failed. This is typically used to signal the general failure
of an asynchronous operation.

<a id="ERR_OPTIONS_BEFORE_BOOTSTRAPPING"></a>

### `ERR_OPTIONS_BEFORE_BOOTSTRAPPING`

<!-- YAML
added: REPLACEME
-->

An attempt was made to get options before the bootstrapping was completed.

<a id="ERR_OUT_OF_RANGE"></a>

### `ERR_OUT_OF_RANGE`
Expand Down
1 change: 1 addition & 0 deletions src/node_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void OOMErrorHandler(const char* location, const v8::OOMDetails& details);
V(ERR_MODULE_NOT_FOUND, Error) \
V(ERR_NON_CONTEXT_AWARE_DISABLED, Error) \
V(ERR_OPERATION_FAILED, TypeError) \
V(ERR_OPTIONS_BEFORE_BOOTSTRAPPING, Error) \
V(ERR_OUT_OF_RANGE, RangeError) \
V(ERR_REQUIRE_ASYNC_MODULE, Error) \
V(ERR_SCRIPT_EXECUTION_INTERRUPTED, Error) \
Expand Down
16 changes: 9 additions & 7 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "env-inl.h"
#include "node_binding.h"
#include "node_errors.h"
#include "node_external_reference.h"
#include "node_internals.h"
#include "node_sea.h"
Expand Down Expand Up @@ -1334,8 +1335,8 @@ void GetCLIOptionsValues(const FunctionCallbackInfo<Value>& args) {

if (!env->has_run_bootstrapping_code()) {
// No code because this is an assertion.
return env->ThrowError(
"Should not query options before bootstrapping is done");
THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING(
isolate, "Should not query options before bootstrapping is done");
}
env->set_has_serialized_options(true);

Expand Down Expand Up @@ -1452,8 +1453,8 @@ void GetCLIOptionsInfo(const FunctionCallbackInfo<Value>& args) {

if (!env->has_run_bootstrapping_code()) {
// No code because this is an assertion.
return env->ThrowError(
"Should not query options before bootstrapping is done");
THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING(
isolate, "Should not query options before bootstrapping is done");
}

Mutex::ScopedLock lock(per_process::cli_options_mutex);
Expand Down Expand Up @@ -1521,7 +1522,8 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
if (!env->has_run_bootstrapping_code()) {
// No code because this is an assertion.
return env->ThrowError(
THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING(
env->isolate(),
"Should not query options before bootstrapping is done");
}
Isolate* isolate = args.GetIsolate();
Expand Down Expand Up @@ -1557,8 +1559,8 @@ void GetEnvOptionsInputType(const FunctionCallbackInfo<Value>& args) {

if (!env->has_run_bootstrapping_code()) {
// No code because this is an assertion.
return env->ThrowError(
"Should not query options before bootstrapping is done");
THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING(
isolate, "Should not query options before bootstrapping is done");
}

Mutex::ScopedLock lock(per_process::cli_options_mutex);
Expand Down

0 comments on commit 16aff57

Please sign in to comment.