From cd01fe26bf7b29c045cf9407d257681045f5fc39 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 11 Aug 2016 19:27:05 +0800 Subject: [PATCH] Better error message when bad --q parameter is passed --- source/net/filebot/cli/CmdlineOperations.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/net/filebot/cli/CmdlineOperations.java b/source/net/filebot/cli/CmdlineOperations.java index 483e542f..9e303837 100644 --- a/source/net/filebot/cli/CmdlineOperations.java +++ b/source/net/filebot/cli/CmdlineOperations.java @@ -390,13 +390,13 @@ public class CmdlineOperations implements CmdlineInterface { } else { log.fine(format("Looking up movie by query [%s]", query)); List results = service.searchMovie(query, locale); - List validResults = applyExpressionFilter(results, filter); - if (validResults.isEmpty()) { + List options = applyExpressionFilter(results, filter); + if (options.isEmpty()) { throw new CmdlineException("Failed to find a valid match: " + results); } // force all mappings - Movie result = (Movie) selectSearchResult(query, validResults, false, strict).get(0); + Movie result = (Movie) selectSearchResult(query, options, false, strict).get(0); for (File file : files) { movieByFile.put(file, result); } @@ -1038,8 +1038,11 @@ public class CmdlineOperations implements CmdlineInterface { Locale locale = getLanguage(languageName).getLocale(); // fetch episode data - SearchResult hit = selectSearchResult(query, service.search(query, locale), false, false).get(0); - List episodes = service.getEpisodeList(hit, sortOrder, locale); + List options = selectSearchResult(query, service.search(query, locale), false, false); + if (options.isEmpty()) + throw new CmdlineException(service.getName() + ": no results"); + + List episodes = service.getEpisodeList(options.get(0), sortOrder, locale); // apply filter episodes = applyExpressionFilter(episodes, filter);