added error handling

This commit is contained in:
2025-11-23 21:35:42 +00:00
parent a70d765361
commit c933b888cb

View File

@@ -34,6 +34,11 @@ func (store *Store) CompleteAuth(c *gin.Context) {
func (store *Store) ListeningTo(c *gin.Context) { func (store *Store) ListeningTo(c *gin.Context) {
ctx := c.Request.Context() ctx := c.Request.Context()
if store.SpotifyClient == nil {
c.JSON(500, gin.H{"error": "Spotify not authenticated"})
return
}
playing, err := store.SpotifyClient.PlayerCurrentlyPlaying(ctx) playing, err := store.SpotifyClient.PlayerCurrentlyPlaying(ctx)
if err != nil { if err != nil {
c.JSON(500, gin.H{"error": err.Error()}) c.JSON(500, gin.H{"error": err.Error()})