Guard watcher constructors against nil clients
This commit is contained in:
parent
8a72b3ebc6
commit
4069bbe263
1 changed files with 8 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue