1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-03-19 06:07:48 +02:00

remind users to call e.Next() in the OnBootstrap hook if the app is still not initilized after the hook trigger

This commit is contained in:
Gani Georgiev 2024-10-06 22:51:39 +03:00
parent 0c2266490f
commit 9087b68651
2 changed files with 10 additions and 1 deletions

View File

@ -381,7 +381,7 @@ func (app *BaseApp) Bootstrap() error {
event := &BootstrapEvent{}
event.App = app
return app.OnBootstrap().Trigger(event, func(e *BootstrapEvent) error {
err := app.OnBootstrap().Trigger(event, func(e *BootstrapEvent) error {
// clear resources of previous core state (if any)
if err := app.ResetBootstrapState(); err != nil {
return err
@ -421,6 +421,14 @@ func (app *BaseApp) Bootstrap() error {
return nil
})
// add a more user friendly message in case users forgot to call
// e.Next() as part of their bootstrap hook
if err == nil && !app.IsBootstrapped() {
app.Logger().Warn("OnBootstrap hook didn't fail but the app is still not bootstrapped - maybe missing e.Next()?")
}
return err
}
type closer interface {

View File

@ -115,6 +115,7 @@ func main() {
},
Priority: 999, // execute as latest as possible to allow users to provide their own route
})
if err := app.Start(); err != nil {
log.Fatal(err)
}