Entire logging rework. Full error handling. Small improvements.

This commit is contained in:
MaxJa4
2024-01-22 17:24:17 +01:00
parent da1ff4e4e5
commit ca697da0da
18 changed files with 278 additions and 205 deletions

View File

@@ -10,7 +10,11 @@ func UintToString(val uint) string {
}
func StringToUint(val string) uint {
res, _ := strconv.ParseUint(val, 10, 16)
res, err := strconv.ParseUint(val, 10, 16)
if err != nil {
Logger.Warnf("StringToUint error for %s: %s", val, err.Error())
return 0
}
return uint(res)
}
@@ -19,6 +23,10 @@ func FloatToString(val float32) string {
}
func StringToFloat(val string) float32 {
res, _ := strconv.ParseFloat(val, 32)
res, err := strconv.ParseFloat(val, 32)
if err != nil {
Logger.Warnf("StringToFloat error for %s: %s", val, err.Error())
return 0
}
return float32(res)
}

View File

@@ -8,7 +8,7 @@ import (
func GenerateActivationCode() string {
bytes := make([]byte, 16)
if _, err := rand.Read(bytes); err != nil {
panic(err) // Handle the error appropriately in production
Logger.Fatalf("Error generating activation code: %v", err)
}
return hex.EncodeToString(bytes)
}