mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
src: print exception thrown during primordial initialization
Otherwise there's little information for debugging if the initialization fails due to a bug in local development. This should generally only happen during the build process, when the snapshot is built. Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com> PR-URL: https://github.com/nodejs/node/pull/65991 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
bfb544eb00
commit
9ec030b1e7
1 file changed
+17
-5
+17
-5
@@ -17,6 +17,7 @@ using v8::MaybeLocal;
|
||||
using v8::Object;
|
||||
using v8::SnapshotCreator;
|
||||
using v8::String;
|
||||
using v8::TryCatch;
|
||||
using v8::Value;
|
||||
|
||||
Realm::Realm(Environment* env, v8::Local<v8::Context> context, Kind kind)
|
||||
@@ -47,11 +48,22 @@ void Realm::CreateProperties() {
|
||||
Local<Context> ctx = context();
|
||||
|
||||
// Store primordials setup by the per-context script in the environment.
|
||||
Local<Object> per_context_bindings =
|
||||
GetPerContextExports(ctx, env_->isolate_data()).ToLocalChecked();
|
||||
Local<Value> primordials =
|
||||
per_context_bindings->Get(ctx, env_->primordials_string())
|
||||
.ToLocalChecked();
|
||||
TryCatch try_catch(isolate_);
|
||||
Local<Object> per_context_bindings;
|
||||
Local<Value> primordials;
|
||||
if (!GetPerContextExports(ctx, env_->isolate_data())
|
||||
.ToLocal(&per_context_bindings) ||
|
||||
!per_context_bindings->Get(ctx, env_->primordials_string())
|
||||
.ToLocal(&primordials)) {
|
||||
// In general, this should only throw exceptions during local development
|
||||
// when there's a temporary bug in the scripts. Print the exception here to
|
||||
// facilitate debugging.
|
||||
if (try_catch.HasCaught() && !try_catch.HasTerminated()) {
|
||||
PrintCaughtException(isolate_, ctx, try_catch);
|
||||
}
|
||||
env_->Exit(ExitCode::kBootstrapFailure);
|
||||
return;
|
||||
}
|
||||
CHECK(primordials->IsObject());
|
||||
set_primordials(primordials.As<Object>());
|
||||
|
||||
|
||||
Reference in new issue
Block a user