Throw a custom error for trakt so it doesn't die in LINQ
This commit is contained in:
parent
7de7b7d599
commit
c7d3a07219
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<List<Show>>(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<Show>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -230,6 +230,7 @@
|
|||
<Compile Include="MediaFiles\Events\SeriesRenamedEvent.cs" />
|
||||
<Compile Include="MediaFiles\RenameEpisodeFileService.cs" />
|
||||
<Compile Include="MediaFiles\UpgradeMediaFileService.cs" />
|
||||
<Compile Include="MetadataSource\Trakt\TraktCommunicationException.cs" />
|
||||
<Compile Include="Notifications\Email\TestEmailCommand.cs" />
|
||||
<Compile Include="Notifications\Growl\GrowlSettings.cs" />
|
||||
<Compile Include="Notifications\Growl\TestGrowlCommand.cs" />
|
||||
|
|
Loading…
Reference in New Issue