small pixel drawing of a pufferfish vore

add more robust handling for feed fetch failures
Jes Olson j3s@c3f.net
Sat, 22 Apr 2023 10:44:43 -0700
commit

9f127ad6462a3b7d85193afc79288637f759f804

parent

d18b80459e4d85944f4615b251711f50b7453a44

2 files changed, 8 insertions(+), 4 deletions(-)

jump to
M reaper/reaper.goreaper/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.gosqlite/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