diff --git a/console.go b/console.go index 9e27faf..09dc3c9 100644 --- a/console.go +++ b/console.go @@ -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)