Better error handling

This commit is contained in:
Deluan
2022-12-28 10:19:52 -05:00
committed by Deluan Quintão
parent 949331ed24
commit bc09de6640
8 changed files with 37 additions and 43 deletions
+7 -4
View File
@@ -52,10 +52,13 @@ func (a *artwork) Get(ctx context.Context, id string, size int) (reader io.ReadC
}
r, err := a.cache.Get(ctx, artReader)
if err != nil && !errors.Is(err, context.Canceled) {
log.Error(ctx, "Error accessing image cache", "id", id, "size", size, err)
if err != nil {
if !errors.Is(err, context.Canceled) {
log.Error(ctx, "Error accessing image cache", "id", id, "size", size, err)
}
return nil, time.Time{}, err
}
return r, artReader.LastUpdated(), err
return r, artReader.LastUpdated(), nil
}
func (a *artwork) getArtworkReader(ctx context.Context, artID model.ArtworkID, size int) (artworkReader, error) {
@@ -72,7 +75,7 @@ func (a *artwork) getArtworkReader(ctx context.Context, artID model.ArtworkID, s
case model.KindPlaylistArtwork:
artReader, err = newPlaylistArtworkReader(ctx, a, artID)
default:
artReader, err = newPlaceholderReader(ctx, artID)
artReader, err = newEmptyIDReader(ctx, artID)
}
}
return artReader, err