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
# Conflicts:
#	main/src/main/java/com/github/topisenpai/lavasrc/mirror/MirroringAudioTrack.java
  • Loading branch information
topi314 committed Aug 8, 2023
1 parent 194d62f commit b8c4c73
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ public void process(LocalAudioTrackExecutor executor) throws Exception {
AudioItem 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.topisenpai.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 b8c4c73

Please sign in to comment.