Skip to content

Commit

Permalink
fix Index 0 out of bounds for length 0
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Aug 8, 2023
1 parent 46e4d46 commit 3e9239f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ public void process(LocalAudioTrackExecutor executor) throws Exception {
}
return;
}
AudioItem track = this.sourceManager.getResolver().apply(this);
var track = this.sourceManager.getResolver().apply(this);

if (track instanceof AudioPlaylist) {
track = ((AudioPlaylist) track).getTracks().get(0);
var tracks = ((AudioPlaylist) track).getTracks();
if (tracks.isEmpty()) {
throw new TrackNotFoundException();
}
track = tracks.get(0);
}
if (track instanceof InternalAudioTrack) {
processDelegate((InternalAudioTrack) track, executor);
return;
}
throw new FriendlyException("No matching track found", FriendlyException.Severity.COMMON, new TrackNotFoundException());
throw new TrackNotFoundException();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package com.github.topi314.lavasrc.mirror;

public class TrackNotFoundException extends RuntimeException {
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;

public class TrackNotFoundException extends FriendlyException {

private static final long serialVersionUID = 6550093849278285754L;

public TrackNotFoundException() {
super("Playlist is empty", FriendlyException.Severity.COMMON, null);
}

}

0 comments on commit 3e9239f

Please sign in to comment.