mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
[v2] Update context error
This commit is contained in:
@@ -8,6 +8,9 @@ import (
|
|||||||
goruntime "runtime"
|
goruntime "runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const contextError = `An invalid context was passed. This method requires the specific context given in the lifecycle hooks:
|
||||||
|
https://wails.io/docs/reference/runtime/intro`
|
||||||
|
|
||||||
func getFrontend(ctx context.Context) frontend.Frontend {
|
func getFrontend(ctx context.Context) frontend.Frontend {
|
||||||
if ctx == nil {
|
if ctx == nil {
|
||||||
pc, _, _, _ := goruntime.Caller(1)
|
pc, _, _, _ := goruntime.Caller(1)
|
||||||
@@ -20,7 +23,7 @@ func getFrontend(ctx context.Context) frontend.Frontend {
|
|||||||
}
|
}
|
||||||
pc, _, _, _ := goruntime.Caller(1)
|
pc, _, _, _ := goruntime.Caller(1)
|
||||||
funcName := goruntime.FuncForPC(pc).Name()
|
funcName := goruntime.FuncForPC(pc).Name()
|
||||||
log.Fatalf("cannot call '%s': Application not initialised", funcName)
|
log.Fatalf("cannot call '%s': %s", funcName, contextError)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func getLogger(ctx context.Context) *logger.Logger {
|
func getLogger(ctx context.Context) *logger.Logger {
|
||||||
@@ -35,7 +38,7 @@ func getLogger(ctx context.Context) *logger.Logger {
|
|||||||
}
|
}
|
||||||
pc, _, _, _ := goruntime.Caller(1)
|
pc, _, _, _ := goruntime.Caller(1)
|
||||||
funcName := goruntime.FuncForPC(pc).Name()
|
funcName := goruntime.FuncForPC(pc).Name()
|
||||||
log.Fatalf("cannot call '%s': Application not initialised", funcName)
|
log.Fatalf("cannot call '%s': %s", funcName, contextError)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +54,7 @@ func getEvents(ctx context.Context) frontend.Events {
|
|||||||
}
|
}
|
||||||
pc, _, _, _ := goruntime.Caller(1)
|
pc, _, _, _ := goruntime.Caller(1)
|
||||||
funcName := goruntime.FuncForPC(pc).Name()
|
funcName := goruntime.FuncForPC(pc).Name()
|
||||||
log.Fatalf("cannot call '%s': Application not initialised", funcName)
|
log.Fatalf("cannot call '%s': %s", funcName, contextError)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ The runtime is a library that provides utility methods for your application. The
|
|||||||
and the aim is to try and keep them at parity where possible.
|
and the aim is to try and keep them at parity where possible.
|
||||||
|
|
||||||
The Go Runtime is available through importing `github.com/wailsapp/wails/v2/pkg/runtime`. All methods in this package
|
The Go Runtime is available through importing `github.com/wailsapp/wails/v2/pkg/runtime`. All methods in this package
|
||||||
take a context as the first parameter. This context can be obtained from the [OnStartup](/docs/reference/options#onstartup)
|
take a context as the first parameter. This context should be obtained from the [OnStartup](/docs/reference/options#onstartup)
|
||||||
or [OnDomReady](/docs/reference/options#ondomready) hooks.
|
or [OnDomReady](/docs/reference/options#ondomready) hooks.
|
||||||
|
|
||||||
:::info Note
|
:::info Note
|
||||||
|
|||||||
Reference in New Issue
Block a user