Skip to content

Commit

Permalink
feat: properly handle warning error for fetching playlists
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <[email protected]>
  • Loading branch information
gleich committed Dec 7, 2024
1 parent 3249111 commit ba261d2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/apis/applemusic/playlists.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package applemusic

import (
"errors"
"fmt"
"time"

"github.com/gleich/lcp-v2/internal/apis"
"github.com/gleich/lumber/v3"
)

Expand Down Expand Up @@ -34,7 +36,9 @@ func fetchPlaylist(id string) (playlist, error) {
fmt.Sprintf("/v1/me/library/playlists/%s", id),
)
if err != nil {
lumber.Error(err, "failed to fetch playlist for", id)
if !errors.Is(err, apis.WarningError) {
lumber.Error(err, "failed to fetch playlist for", id)
}
return playlist{}, err
}

Expand All @@ -49,7 +53,9 @@ func fetchPlaylist(id string) (playlist, error) {
for trackData.Next != "" {
trackData, err = sendAppleMusicAPIRequest[playlistTracksResponse](trackData.Next)
if err != nil {
lumber.Error(err, "failed to paginate through tracks for playlist with id of", id)
if !errors.Is(err, apis.WarningError) {
lumber.Error(err, "failed to paginate through tracks for playlist with id of", id)
}
return playlist{}, err
}
totalResponseData = append(totalResponseData, trackData.Data...)
Expand Down

0 comments on commit ba261d2

Please sign in to comment.