From ac2ff63e60bba8e841746a067f27441e491f4235 Mon Sep 17 00:00:00 2001 From: said belhadj Date: Sun, 27 Jun 2021 16:56:11 +0200 Subject: Catch exception related to search functionality --- src/main/java/musichub/business/MusicHub.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/musichub/business') diff --git a/src/main/java/musichub/business/MusicHub.java b/src/main/java/musichub/business/MusicHub.java index bbac505..660f0f8 100644 --- a/src/main/java/musichub/business/MusicHub.java +++ b/src/main/java/musichub/business/MusicHub.java @@ -340,7 +340,7 @@ public class MusicHub { } - public void searchAudioElement() throws UnsupportedAudioFileException, NoAlbumFoundException, LineUnavailableException, IOException { + public void searchAudioElement() throws UnsupportedAudioFileException, NoAlbumFoundException, LineUnavailableException, IOException, NoElementFoundException { Scanner scanner = new Scanner(System.in); System.out.println("Entrez le titre ou l'artiste de la musique que vous souhaitez chercher dans la base de données"); String word = scanner.next().toLowerCase(Locale.ROOT); @@ -353,7 +353,7 @@ public class MusicHub { } if(searchResult.isEmpty()){ - System.err.println("Aucun résultat pour votre recherche"); + throw new NoElementFoundException("Any result for your search"); } if (searchResult.size()==1){ this.getAudioElement(searchResult, searchResult.get(0).getTitle()); -- cgit v1.2.3