From cffba202b0f7e0cab0445290f988d62cdbd1dfff Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Tue, 6 Mar 2018 19:33:22 +0100 Subject: [PATCH] Now the server does not crash when unable to search plex. --- seasoned_api/src/plex/plexRepository.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/seasoned_api/src/plex/plexRepository.js b/seasoned_api/src/plex/plexRepository.js index c02a65a..0a506c6 100644 --- a/seasoned_api/src/plex/plexRepository.js +++ b/seasoned_api/src/plex/plexRepository.js @@ -6,7 +6,12 @@ class PlexRepository { inPlex(tmdbResult) { return Promise.resolve() .then(() => this.search(tmdbResult.title)) - .then(plexResult => this.compareTmdbToPlex(tmdbResult, plexResult)); + .then(plexResult => this.compareTmdbToPlex(tmdbResult, plexResult)) + .catch((error) => { + console.log(error) + tmdbResult.matchedInPlex = false; + return tmdbResult; + }); } search(query) { @@ -19,6 +24,9 @@ class PlexRepository { }; return rp(options) + .catch((error) => { + throw new Error('Unable to search plex.') + }) .then(result => this.mapResults(result)) .then(([mappedResults, resultCount]) => ({ results: mappedResults, total_results: resultCount })); }