refactor(store): add error returns to all Store interface methods
Every Store method now returns an error. Callers handle errors gracefully — TUI logs to event log, server returns HTTP 500, monitor engine logs and retries. All rows.Scan() errors are now checked in sqlstore.go instead of silently appending corrupt data. - GetSites, GetAllAlerts, GetAllUsers return ([]T, error) - GetAlert returns (AlertConfig, error) instead of (AlertConfig, bool) - AddSite, UpdateSite, DeleteSite, etc. all return error - SaveCheck, LoadAllHistory, ExportData return error - ~25 caller sites updated across tui, server, monitor, main
This commit is contained in:
@@ -128,7 +128,12 @@ func StartEngine() {
|
||||
continue
|
||||
}
|
||||
|
||||
sites := s_instance.GetSites()
|
||||
sites, err := s_instance.GetSites()
|
||||
if err != nil {
|
||||
AddLog(fmt.Sprintf("Failed to load sites: %v", err))
|
||||
time.Sleep(5 * time.Second)
|
||||
continue
|
||||
}
|
||||
for _, s := range sites {
|
||||
Mutex.RLock()
|
||||
_, exists := LiveState[s.ID]
|
||||
@@ -406,8 +411,8 @@ func triggerAlert(alertID int, title, message string) {
|
||||
if s_instance == nil {
|
||||
return
|
||||
}
|
||||
cfg, ok := s_instance.GetAlert(alertID)
|
||||
if !ok {
|
||||
cfg, err := s_instance.GetAlert(alertID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
provider := alert.GetProvider(cfg)
|
||||
|
||||
Reference in New Issue
Block a user