mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-09 13:58:05 -05:00
Better Error Handling for #6
This commit is contained in:
12
spt/get.go
12
spt/get.go
@@ -266,12 +266,20 @@ func GetPlayerState() (*spotify.PlayerState, error) {
|
||||
|
||||
func GetTopTracks() ([]spotify.FullTrack, error) {
|
||||
c, err := Client.CurrentUsersTopTracks(ctx(), spotify.Limit(topTracksLimit))
|
||||
return c.Tracks, err
|
||||
if c != nil {
|
||||
return c.Tracks, err
|
||||
} else {
|
||||
return []spotify.FullTrack{}, errors.New("No Top Tracks Found!")
|
||||
}
|
||||
}
|
||||
|
||||
func GetTopArtists() ([]spotify.FullArtist, error) {
|
||||
c, err := Client.CurrentUsersTopArtists(ctx(), spotify.Limit(topTracksLimit))
|
||||
return c.Artists, err
|
||||
if c != nil {
|
||||
return c.Artists, err
|
||||
} else {
|
||||
return []spotify.FullArtist{}, errors.New("No Top Artists Found!")
|
||||
}
|
||||
}
|
||||
|
||||
func GetArtistTopTracks(artistID spotify.ID) ([]spotify.FullTrack, error) {
|
||||
|
||||
Reference in New Issue
Block a user