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:
@@ -25,7 +25,11 @@ func InitHistoryFromStore() {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
all := s.LoadAllHistory(maxHistoryLen)
|
||||
all, err := s.LoadAllHistory(maxHistoryLen)
|
||||
if err != nil {
|
||||
AddLog("Failed to load check history: " + err.Error())
|
||||
return
|
||||
}
|
||||
historyMu.Lock()
|
||||
defer historyMu.Unlock()
|
||||
for siteID, records := range all {
|
||||
@@ -71,7 +75,7 @@ func RecordCheck(siteID int, latency time.Duration, isUp bool) {
|
||||
}
|
||||
|
||||
if s := store.Get(); s != nil {
|
||||
go s.SaveCheck(siteID, latency.Nanoseconds(), isUp)
|
||||
go func() { _ = s.SaveCheck(siteID, latency.Nanoseconds(), isUp) }()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user