Skip to content

Commit

Permalink
feat: properly check for warning error
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <[email protected]>
  • Loading branch information
gleich committed Dec 4, 2024
1 parent 3a81276 commit a50a20e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (c *Cache[T]) Update(data T) {
lumber.Error(err, "failed to json marshal new data")
return
}
if string(old) != string(new) && string(new) != "null" {
if string(old) != string(new) && string(new) != "null" && strings.Trim(string(new), " ") != "" {
c.data = data
c.updated = time.Now()
updated = true
Expand All @@ -104,8 +104,12 @@ func (c *Cache[T]) StartPeriodicUpdate(updateFunc func() (T, error), interval ti
defer ticker.Stop()
for range ticker.C {
data, err := updateFunc()
if err != nil && !errors.Is(err, apis.WarningError) {
lumber.Error(err, "updating", c.name, "cache failed")
if err != nil {
if errors.Is(err, apis.WarningError) {
lumber.Warning(err, "updating", c.name, "cache failed")
} else {
lumber.Error(err, "updating", c.name, "cache failed")
}
continue
}
c.Update(data)
Expand Down

0 comments on commit a50a20e

Please sign in to comment.