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:
@@ -2,6 +2,7 @@ package tui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go-upkeep/internal/monitor"
|
||||
"go-upkeep/internal/store"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
@@ -277,9 +278,13 @@ func (m *Model) submitAlertForm() {
|
||||
}
|
||||
|
||||
if m.editID > 0 {
|
||||
store.Get().UpdateAlert(m.editID, d.Name, d.AlertType, settings)
|
||||
if err := store.Get().UpdateAlert(m.editID, d.Name, d.AlertType, settings); err != nil {
|
||||
monitor.AddLog("Update alert failed: " + err.Error())
|
||||
}
|
||||
} else {
|
||||
store.Get().AddAlert(d.Name, d.AlertType, settings)
|
||||
if err := store.Get().AddAlert(d.Name, d.AlertType, settings); err != nil {
|
||||
monitor.AddLog("Add alert failed: " + err.Error())
|
||||
}
|
||||
}
|
||||
m.state = stateDashboard
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user