Guard watcher constructors against nil clients
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

This commit is contained in:
Snider 2026-04-15 23:52:21 +01:00
parent 8a72b3ebc6
commit 4069bbe263

View file

@ -49,6 +49,10 @@ func NewConsoleWatcher(wv *Webview) *ConsoleWatcher {
handlers: make([]consoleHandlerRegistration, 0),
}
if wv == nil || wv.client == nil {
return watcher
}
// Subscribe to console events from the webview's client
wv.client.OnEvent("Runtime.consoleAPICalled", func(params map[string]any) {
watcher.handleConsoleEvent(params)
@ -529,6 +533,10 @@ func NewExceptionWatcher(wv *Webview) *ExceptionWatcher {
handlers: make([]exceptionHandlerRegistration, 0),
}
if wv == nil || wv.client == nil {
return ew
}
// Subscribe to exception events
wv.client.OnEvent("Runtime.exceptionThrown", func(params map[string]any) {
ew.handleException(params)