Skip to content

Commit 8f36a2c

Browse files
marco-ippolitoaduh95
authored andcommitted
src: create THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING
PR-URL: #57016 Backport-PR-URL: #57958 Refs: #53787 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Tierney Cyren <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
1 parent cc6fef9 commit 8f36a2c

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

doc/api/errors.md

+10
Original file line numberDiff line numberDiff line change
@@ -2388,6 +2388,16 @@ added: v15.0.0
23882388
An operation failed. This is typically used to signal the general failure
23892389
of an asynchronous operation.
23902390

2391+
<a id="ERR_OPTIONS_BEFORE_BOOTSTRAPPING"></a>
2392+
2393+
### `ERR_OPTIONS_BEFORE_BOOTSTRAPPING`
2394+
2395+
<!-- YAML
2396+
added: REPLACEME
2397+
-->
2398+
2399+
An attempt was made to get options before the bootstrapping was completed.
2400+
23912401
<a id="ERR_OUT_OF_RANGE"></a>
23922402

23932403
### `ERR_OUT_OF_RANGE`

src/node_errors.h

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ void OOMErrorHandler(const char* location, const v8::OOMDetails& details);
105105
V(ERR_MISSING_PLATFORM_FOR_WORKER, Error) \
106106
V(ERR_MODULE_NOT_FOUND, Error) \
107107
V(ERR_NON_CONTEXT_AWARE_DISABLED, Error) \
108+
V(ERR_OPTIONS_BEFORE_BOOTSTRAPPING, Error) \
108109
V(ERR_OUT_OF_RANGE, RangeError) \
109110
V(ERR_REQUIRE_ASYNC_MODULE, Error) \
110111
V(ERR_SCRIPT_EXECUTION_INTERRUPTED, Error) \

src/node_options.cc

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "env-inl.h"
55
#include "node_binding.h"
6+
#include "node_errors.h"
67
#include "node_external_reference.h"
78
#include "node_internals.h"
89
#include "node_sea.h"
@@ -1362,8 +1363,8 @@ void GetCLIOptionsValues(const FunctionCallbackInfo<Value>& args) {
13621363

13631364
if (!env->has_run_bootstrapping_code()) {
13641365
// No code because this is an assertion.
1365-
return env->ThrowError(
1366-
"Should not query options before bootstrapping is done");
1366+
THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING(
1367+
isolate, "Should not query options before bootstrapping is done");
13671368
}
13681369
env->set_has_serialized_options(true);
13691370

@@ -1480,8 +1481,8 @@ void GetCLIOptionsInfo(const FunctionCallbackInfo<Value>& args) {
14801481

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

14871488
Mutex::ScopedLock lock(per_process::cli_options_mutex);
@@ -1547,7 +1548,8 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
15471548
Environment* env = Environment::GetCurrent(args);
15481549
if (!env->has_run_bootstrapping_code()) {
15491550
// No code because this is an assertion.
1550-
return env->ThrowError(
1551+
THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING(
1552+
env->isolate(),
15511553
"Should not query options before bootstrapping is done");
15521554
}
15531555
Isolate* isolate = args.GetIsolate();
@@ -1583,8 +1585,8 @@ void GetEnvOptionsInputType(const FunctionCallbackInfo<Value>& args) {
15831585

15841586
if (!env->has_run_bootstrapping_code()) {
15851587
// No code because this is an assertion.
1586-
return env->ThrowError(
1587-
"Should not query options before bootstrapping is done");
1588+
THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING(
1589+
isolate, "Should not query options before bootstrapping is done");
15881590
}
15891591

15901592
Mutex::ScopedLock lock(per_process::cli_options_mutex);

0 commit comments

Comments
 (0)