add error handling for reading configuration #1

Merged
arya merged 9 commits from odyseusz/publapi:master into master 2024-11-04 20:20:30 +05:30
Showing only changes of commit 92b6cf890b - Show all commits

View File

@ -92,7 +92,24 @@ func userdata(username, usersonline, ops string) Userinfo {
} }
} }
viper.SetConfigFile(filename) 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 var user Userinfo
user = Userinfo{} user = Userinfo{}
user.Name = username user.Name = username