fix topic store error surfacing
reduce boilerplate in database.go
This commit is contained in:
parent
5bdda5c573
commit
a7b2659cde
25
database.go
25
database.go
|
@ -27,21 +27,22 @@ func InitDatabase() (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
globs = &Globs{stmts}
|
globs = &Globs{stmts}
|
||||||
|
ws := errors.WithStack
|
||||||
|
|
||||||
log.Print("Running the db handlers.")
|
log.Print("Running the db handlers.")
|
||||||
err = c.DbInits.Run()
|
err = c.DbInits.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Loading the usergroups.")
|
log.Print("Loading the usergroups.")
|
||||||
c.Groups, err = c.NewMemoryGroupStore()
|
c.Groups, err = c.NewMemoryGroupStore()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
err2 := c.Groups.LoadGroups()
|
err2 := c.Groups.LoadGroups()
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
return errors.WithStack(err2)
|
return ws(err2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to put this here, otherwise LoadForums() won't be able to get the last poster data when building it's forums
|
// We have to put this here, otherwise LoadForums() won't be able to get the last poster data when building it's forums
|
||||||
|
@ -58,49 +59,49 @@ func InitDatabase() (err error) {
|
||||||
|
|
||||||
c.Users, err = c.NewDefaultUserStore(ucache)
|
c.Users, err = c.NewDefaultUserStore(ucache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
c.Topics, err = c.NewDefaultTopicStore(tcache)
|
c.Topics, err = c.NewDefaultTopicStore(tcache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err2)
|
return ws(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Loading the forums.")
|
log.Print("Loading the forums.")
|
||||||
c.Forums, err = c.NewMemoryForumStore()
|
c.Forums, err = c.NewMemoryForumStore()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
err = c.Forums.LoadForums()
|
err = c.Forums.LoadForums()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Loading the forum permissions.")
|
log.Print("Loading the forum permissions.")
|
||||||
c.FPStore, err = c.NewMemoryForumPermsStore()
|
c.FPStore, err = c.NewMemoryForumPermsStore()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
err = c.FPStore.Init()
|
err = c.FPStore.Init()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Loading the settings.")
|
log.Print("Loading the settings.")
|
||||||
err = c.LoadSettings()
|
err = c.LoadSettings()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Loading the plugins.")
|
log.Print("Loading the plugins.")
|
||||||
err = c.InitExtend()
|
err = c.InitExtend()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Loading the themes.")
|
log.Print("Loading the themes.")
|
||||||
err = c.Themes.LoadActiveStatus()
|
err = c.Themes.LoadActiveStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue