diff --git a/NzbDrone.Core/MetadataSource/Trakt/TraktCommunicationException.cs b/NzbDrone.Core/MetadataSource/Trakt/TraktCommunicationException.cs new file mode 100644 index 000000000..d09dad66c --- /dev/null +++ b/NzbDrone.Core/MetadataSource/Trakt/TraktCommunicationException.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Core.MetadataSource.Trakt +{ + public class TraktCommunicationException : Exception + { + public TraktCommunicationException(string message, Exception innerException) : base(message, innerException) + { + } + } +} diff --git a/NzbDrone.Core/MetadataSource/TraktProxy.cs b/NzbDrone.Core/MetadataSource/TraktProxy.cs index 15cfc87d1..99bfd09da 100644 --- a/NzbDrone.Core/MetadataSource/TraktProxy.cs +++ b/NzbDrone.Core/MetadataSource/TraktProxy.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Net; using System.Text.RegularExpressions; using NzbDrone.Common; using NzbDrone.Core.MediaCover; @@ -20,6 +21,8 @@ namespace NzbDrone.Core.MetadataSource var restRequest = new RestRequest(title.ToSearchTerm()); var response = client.Execute>(restRequest); + CheckForError(response); + return response.Data.Select(MapSeries).ToList(); } @@ -29,6 +32,8 @@ namespace NzbDrone.Core.MetadataSource var restRequest = new RestRequest(tvDbSeriesId.ToString() + "/extended"); var response = client.Execute(restRequest); + CheckForError(response); + var episodes = response.Data.seasons.SelectMany(c => c.episodes).Select(MapEpisode).ToList(); var series = MapSeries(response.Data); @@ -120,5 +125,13 @@ namespace NzbDrone.Core.MetadataSource return match.Captures[0].Value; } + + private void CheckForError(IRestResponse response) + { + if (response.StatusCode != HttpStatusCode.OK) + { + throw new TraktCommunicationException(response.ErrorMessage, response.ErrorException); + } + } } } \ No newline at end of file diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 2ff65b46a..b717a5269 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -230,6 +230,7 @@ +