Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
src: create THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING
  • Loading branch information
marco-ippolito committed Feb 20, 2025
commit a7ee7064e77d87d316b35a8cf682be4b2603c87b
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 @@ -1344,8 +1345,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 @@ -1466,8 +1467,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 @@ -1535,7 +1536,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 @@ -1571,8 +1573,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