void MainThreadDebugger::exceptionThrown(ExecutionContext* context, ErrorEvent* event) { LocalFrame* frame = nullptr; ScriptState* scriptState = nullptr; if (context->isDocument()) { frame = toDocument(context)->frame(); if (!frame) return; scriptState = event->world() ? ScriptState::forWorld(frame, *event->world()) : nullptr; } else if (context->isMainThreadWorkletGlobalScope()) { frame = toMainThreadWorkletGlobalScope(context)->frame(); if (!frame) return; scriptState = toMainThreadWorkletGlobalScope(context) ->scriptController() ->getScriptState(); } else { NOTREACHED(); } frame->console().reportMessageToClient(JSMessageSource, ErrorMessageLevel, event->messageForConsole(), event->location()); const String defaultMessage = "Uncaught"; if (scriptState && scriptState->contextIsValid()) { ScriptState::Scope scope(scriptState); v8::Local<v8::Value> exception = V8ErrorHandler::loadExceptionFromErrorEventWrapper( scriptState, event, scriptState->context()->Global()); SourceLocation* location = event->location(); String message = event->messageForConsole(); String url = location->url(); v8Inspector()->exceptionThrown( scriptState->context(), toV8InspectorStringView(defaultMessage), exception, toV8InspectorStringView(message), toV8InspectorStringView(url), location->lineNumber(), location->columnNumber(), location->takeStackTrace(), location->scriptId()); } }