try to make playback index out of range log more useful

This commit is contained in:
Drew Weymouth
2025-11-11 08:36:34 -08:00
parent 8b73765a7d
commit 7266030e43
+3 -2
View File
@@ -3,6 +3,7 @@ package backend
import (
"context"
"errors"
"fmt"
"log"
"math/rand"
"time"
@@ -223,8 +224,8 @@ func (p *playbackEngine) PlayTrackAt(idx int) error {
}
func (p *playbackEngine) playTrackAt(idx int, startTime float64) error {
if idx < 0 || idx >= len(p.playQueue) {
return errors.New("track index out of range")
if l := len(p.playQueue); idx < 0 || idx >= l {
return fmt.Errorf("track index (%d) out of range (0-%d)", idx, l)
}
// scrobble current track if needed
p.checkScrobble()