add error handling for reading configuration

This commit is contained in:
odyseusz 2024-09-28 17:58:17 +02:00
parent 2298cbeeee
commit 92b6cf890b

View File

@ -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