@@ -427,8 +427,11 @@ class FInspector : public IJavascriptInspector, public FTickableAnyObject, publi
427427 FIsolateHelper I (isolate_);
428428
429429 {
430- auto console = InContext->Global ()->Get (I.Keyword (" console" ));
431- InContext->Global ()->Set (I.Keyword (" $console" ), console);
430+ auto console = InContext->Global ()->Get (InContext, I.Keyword (" console" ));
431+ if (!console.IsEmpty ())
432+ {
433+ InContext->Global ()->Set (InContext, I.Keyword (" $console" ), console.ToLocalChecked ());
434+ }
432435 }
433436
434437 v8inspector = v8_inspector::V8Inspector::create (isolate_, this );
@@ -487,33 +490,43 @@ class FInspector : public IJavascriptInspector, public FTickableAnyObject, publi
487490 HandleScope handle_scope (isolate_);
488491
489492 FIsolateHelper I (isolate_);
490-
493+ auto context_ = context ();
491494 Isolate::Scope isolate_scope (isolate_);
492- Context::Scope context_scope (context () );
495+ Context::Scope context_scope (context_ );
493496
494497 TryCatch try_catch (isolate_);
495498
496- auto console = context ()->Global ()->Get (I.Keyword (" console" )).As <v8::Object>();
499+ auto maybe_console = context_->Global ()->Get (context_, I.Keyword (" console" ));
500+ if (!maybe_console.IsEmpty ())
501+ {
502+ auto console = maybe_console.ToLocalChecked ().As <v8::Object>();
497503
498- auto method =
499- Verbosity == ELogVerbosity::Fatal || Verbosity == ELogVerbosity::Error ? I.Keyword (" $error" ) :
500- Verbosity == ELogVerbosity::Warning ? I.Keyword (" $warn" ) :
501- Verbosity == ELogVerbosity::Display ? I.Keyword (" info" ) :
502- I.Keyword (" $log" );
503- auto function = console->Get (method).As <v8::Function>();
504+ auto method =
505+ Verbosity == ELogVerbosity::Fatal || Verbosity == ELogVerbosity::Error ? I.Keyword (" $error" ) :
506+ Verbosity == ELogVerbosity::Warning ? I.Keyword (" $warn" ) :
507+ Verbosity == ELogVerbosity::Display ? I.Keyword (" info" ) :
508+ I.Keyword (" $log" );
504509
505- if (Verbosity == ELogVerbosity::Display)
506- {
507- Handle<Value> argv[2 ];
508- argv[0 ] = I.String (FString::Printf (TEXT (" %%c%s: %s" ), *Category.ToString (), V));
509- argv[1 ] = I.String (TEXT (" color:gray" ));
510- (void )function->Call (context (), console, 2 , argv);
511- }
512- else
513- {
514- Handle<Value> argv[1 ];
515- argv[0 ] = I.String (FString::Printf (TEXT (" %s: %s" ), *Category.ToString (), V));
516- (void )function->Call (context (), console, 1 , argv);
510+ auto maybe_function = console->Get (context_, method);
511+
512+ if (!maybe_function.IsEmpty ())
513+ {
514+ auto function = maybe_function.ToLocalChecked ().As <v8::Function>();
515+
516+ if (Verbosity == ELogVerbosity::Display)
517+ {
518+ Handle<Value> argv[2 ];
519+ argv[0 ] = I.String (FString::Printf (TEXT (" %%c%s: %s" ), *Category.ToString (), V));
520+ argv[1 ] = I.String (TEXT (" color:gray" ));
521+ (void )function->Call (context (), console, 2 , argv);
522+ }
523+ else
524+ {
525+ Handle<Value> argv[1 ];
526+ argv[0 ] = I.String (FString::Printf (TEXT (" %s: %s" ), *Category.ToString (), V));
527+ (void )function->Call (context (), console, 1 , argv);
528+ }
529+ }
517530 }
518531 }
519532 }
0 commit comments