add more robust handling for feed fetch failures
Jes Olson j3s@c3f.net
Sat, 22 Apr 2023 10:44:43 -0700
2 files changed,
8 insertions(+),
4 deletions(-)
M
reaper/reaper.go
→
reaper/reaper.go
@@ -85,13 +85,16 @@ }
return true } -// updateFeed triggers a fetch on the given feed, +// refreshFeed triggers a fetch on the given feed, // and sets a fetch error in the db if there is one. func (r *Reaper) refreshFeed(f *rss.Feed) { err := f.Update() if err != nil { fmt.Printf("[err] reaper: fetch failure '%s': %s\n", f.UpdateURL, err) - r.db.SetFeedFetchError(f.UpdateURL, err.Error()) + err = r.db.SetFeedFetchError(f.UpdateURL, err.Error()) + if err != nil { + fmt.Printf("[err] reaper: could not set feed fetch error '%s'\n", err) + } } }
M
sqlite/sql.go
→
sqlite/sql.go
@@ -209,11 +209,12 @@ }
// WriteFeed writes an rss feed to the database for permanent storage // if the given feed already exists, WriteFeed does nothing. -func (s *DB) SetFeedFetchError(url string, fetchErr string) { +func (s *DB) SetFeedFetchError(url string, fetchErr string) error { _, err := s.sql.Exec("UPDATE feed SET fetch_error=? WHERE url=?", fetchErr, url) if err != nil { - panic(err) + return err } + return nil } // WriteFeed writes an rss feed to the database for permanent storage