From 92b6cf890bbe3db4121d7d31a71943de93aca7ca Mon Sep 17 00:00:00 2001 From: odyseusz <4pt5r3kf2@mozmail.com> Date: Sat, 28 Sep 2024 17:58:17 +0200 Subject: [PATCH] add error handling for reading configuration --- pages/users.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pages/users.go b/pages/users.go index 5229e36..a15fdf6 100644 --- a/pages/users.go +++ b/pages/users.go @@ -92,7 +92,24 @@ func userdata(username, usersonline, ops string) Userinfo { } } viper.SetConfigFile(filename) - viper.ReadInConfig() + if err := viper.ReadInConfig(); err != nil { + log.Error("Couldn't read a users meta-info.toml file.", err, username) + user := Userinfo{ + Name: username, + } + user.Created, _ = strconv.Atoi(crdstr) + if isonline { + user.Online = true + } else { + user.Online = false + } + if isop { + user.Op = true + } else { + user.Op = false + } + return user + } var user Userinfo user = Userinfo{} user.Name = username