diff --git a/main/src/main/java/com/github/topi314/lavasrc/mirror/MirroringAudioTrack.java b/main/src/main/java/com/github/topi314/lavasrc/mirror/MirroringAudioTrack.java index f74519e5..cadbe1d8 100644 --- a/main/src/main/java/com/github/topi314/lavasrc/mirror/MirroringAudioTrack.java +++ b/main/src/main/java/com/github/topi314/lavasrc/mirror/MirroringAudioTrack.java @@ -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 diff --git a/main/src/main/java/com/github/topi314/lavasrc/mirror/TrackNotFoundException.java b/main/src/main/java/com/github/topi314/lavasrc/mirror/TrackNotFoundException.java index 9df7eea5..c59a10db 100644 --- a/main/src/main/java/com/github/topi314/lavasrc/mirror/TrackNotFoundException.java +++ b/main/src/main/java/com/github/topi314/lavasrc/mirror/TrackNotFoundException.java @@ -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); + } + }