Now the server does not crash when unable to search plex.

This commit is contained in:
2018-03-06 19:33:22 +01:00
parent d3b4a34298
commit cffba202b0

View File

@@ -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 }));
}