voidAgent::ToggleAsyncHook(Isolate* isolate, Local<Function> fn){ // Guard against running this during cleanup -- no async events will be // emitted anyway at that point anymore, and calling into JS is not possible. // This should probably not be something we're attempting in the first place, // Refs: https://github.com/nodejs/node/pull/34362#discussion_r456006039 if (!parent_env_->can_call_into_js()) return; CHECK(parent_env_->has_run_bootstrapping_code()); HandleScope handle_scope(isolate); CHECK(!fn.IsEmpty()); auto context = parent_env_->context(); v8::TryCatch try_catch(isolate); USE(fn->Call(context, Undefined(isolate), 0, nullptr)); if (try_catch.HasCaught() && !try_catch.HasTerminated()) { PrintCaughtException(isolate, context, try_catch); FatalError("\nnode::inspector::Agent::ToggleAsyncHook", "Cannot toggle Inspector's AsyncHook, please report this."); } }
SetVerbose
Set verbosity of the external exception handler. By default, exceptions that are caught by an external exception handler are not reported. Call SetVerbose with true on an external exception handler to have exceptions caught by the handler reported as if they were not caught.
voidTriggerUncaughtException(Isolate* isolate, const v8::TryCatch& try_catch){ // If the try_catch is verbose, the per-isolate message listener is going to // handle it (which is going to call into another overload of // TriggerUncaughtException()). if (try_catch.IsVerbose()) { return; }
// If the user calls TryCatch::TerminateExecution() on this TryCatch // they must call CancelTerminateExecution() again before invoking // TriggerUncaughtException() because it will invoke // process._fatalException() in the JS land. CHECK(!try_catch.HasTerminated()); CHECK(try_catch.HasCaught()); HandleScope scope(isolate); TriggerUncaughtException(isolate, try_catch.Exception(), try_catch.Message(), false/* from_promise */); }