From a7b2659cdec31c7de4f534fa3aa9895840566527 Mon Sep 17 00:00:00 2001 From: Azareal Date: Thu, 8 Apr 2021 15:01:27 +1000 Subject: [PATCH] fix topic store error surfacing reduce boilerplate in database.go --- database.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/database.go b/database.go index bc0bb757..b6cf2a5b 100644 --- a/database.go +++ b/database.go @@ -27,21 +27,22 @@ func InitDatabase() (err error) { return err } globs = &Globs{stmts} + ws := errors.WithStack log.Print("Running the db handlers.") err = c.DbInits.Run() if err != nil { - return errors.WithStack(err) + return ws(err) } log.Print("Loading the usergroups.") c.Groups, err = c.NewMemoryGroupStore() if err != nil { - return errors.WithStack(err) + return ws(err) } err2 := c.Groups.LoadGroups() 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 @@ -58,49 +59,49 @@ func InitDatabase() (err error) { c.Users, err = c.NewDefaultUserStore(ucache) if err != nil { - return errors.WithStack(err) + return ws(err) } c.Topics, err = c.NewDefaultTopicStore(tcache) if err != nil { - return errors.WithStack(err2) + return ws(err) } log.Print("Loading the forums.") c.Forums, err = c.NewMemoryForumStore() if err != nil { - return errors.WithStack(err) + return ws(err) } err = c.Forums.LoadForums() if err != nil { - return errors.WithStack(err) + return ws(err) } log.Print("Loading the forum permissions.") c.FPStore, err = c.NewMemoryForumPermsStore() if err != nil { - return errors.WithStack(err) + return ws(err) } err = c.FPStore.Init() if err != nil { - return errors.WithStack(err) + return ws(err) } log.Print("Loading the settings.") err = c.LoadSettings() if err != nil { - return errors.WithStack(err) + return ws(err) } log.Print("Loading the plugins.") err = c.InitExtend() if err != nil { - return errors.WithStack(err) + return ws(err) } log.Print("Loading the themes.") err = c.Themes.LoadActiveStatus() if err != nil { - return errors.WithStack(err) + return ws(err) } return nil }