diff --git a/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs b/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs index 02fde70dad..b4e78b5ef6 100644 --- a/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs +++ b/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs @@ -50,13 +50,14 @@ public void should_execute_get_using_gzip(string compression) [TestCase(HttpStatusCode.InternalServerError)] [TestCase(HttpStatusCode.ServiceUnavailable)] [TestCase(HttpStatusCode.BadGateway)] - public void should_throw_on_unsuccessful_status_codes(HttpStatusCode statusCode) + [TestCase(429)] + public void should_throw_on_unsuccessful_status_codes(int statusCode) { - var request = new HttpRequest("http://eu.httpbin.org/status/" + (int)statusCode); + var request = new HttpRequest("http://eu.httpbin.org/status/" + statusCode); var exception = Assert.Throws(() => Subject.Get(request)); - exception.Response.StatusCode.Should().Be(statusCode); + ((int)exception.Response.StatusCode).Should().Be(statusCode); ExceptionVerification.IgnoreWarns(); } diff --git a/src/NzbDrone.Common/Exceptron/ExceptionExtentions.cs b/src/NzbDrone.Common/Exceptron/ExceptionExtentions.cs new file mode 100644 index 0000000000..945ceb0d0b --- /dev/null +++ b/src/NzbDrone.Common/Exceptron/ExceptionExtentions.cs @@ -0,0 +1,31 @@ +using System; +using NzbDrone.Common.EnvironmentInfo; + +namespace NzbDrone.Common.Exceptron +{ + public static class ExceptionExtentions + { + private const string IGNORE_FLAG = "exceptron_ignore"; + + public static Exception ExceptronIgnoreOnMono(this Exception exception) + { + if (OsInfo.IsMono) + { + exception.ExceptronIgnore(); + } + + return exception; + } + + public static Exception ExceptronIgnore(this Exception exception) + { + exception.Data.Add(IGNORE_FLAG, true); + return exception; + } + + public static bool ExceptronShouldIgnore(this Exception exception) + { + return exception.Data.Contains(IGNORE_FLAG); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Common/Exceptron/ExceptronClient.cs b/src/NzbDrone.Common/Exceptron/ExceptronClient.cs index a84c64b002..5dca71a4b9 100644 --- a/src/NzbDrone.Common/Exceptron/ExceptronClient.cs +++ b/src/NzbDrone.Common/Exceptron/ExceptronClient.cs @@ -3,39 +3,11 @@ using System.Diagnostics; using System.Reflection; using System.Threading; -using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Exceptron.Configuration; using NzbDrone.Common.Exceptron.Message; namespace NzbDrone.Common.Exceptron { - - public static class ExceptionExtentions - { - private const string IgnoreFlag = "exceptron_ignore"; - - public static Exception ExceptronIgnoreOnMono(this Exception exception) - { - if (OsInfo.IsMono) - { - exception.ExceptronIgnore(); - } - - return exception; - } - - public static Exception ExceptronIgnore(this Exception exception) - { - exception.Data.Add(IgnoreFlag, true); - return exception; - } - - public static bool ExceptronShouldIgnore(this Exception exception) - { - return exception.Data.Contains(IgnoreFlag); - } - } - public class ExceptronClient : IExceptronClient { internal IRestClient RestClient { private get; set; } diff --git a/src/NzbDrone.Common/Http/HttpException.cs b/src/NzbDrone.Common/Http/HttpException.cs index 3c8e382492..626d177740 100644 --- a/src/NzbDrone.Common/Http/HttpException.cs +++ b/src/NzbDrone.Common/Http/HttpException.cs @@ -8,7 +8,7 @@ public class HttpException : Exception public HttpResponse Response { get; private set; } public HttpException(HttpRequest request, HttpResponse response) - : base(string.Format("HTTP request failed: [{0}] [{1}] at [{2}]", (int)response.StatusCode, request.Method, request.Url.ToString())) + : base(string.Format("HTTP request failed: [{0}:{1}] [{2}] at [{3}]", (int)response.StatusCode, response.StatusCode, request.Method, request.Url.ToString())) { Request = request; Response = response; diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj index b697320b37..99c9668914 100644 --- a/src/NzbDrone.Common/NzbDrone.Common.csproj +++ b/src/NzbDrone.Common/NzbDrone.Common.csproj @@ -103,6 +103,7 @@ + diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index 6f57b8132f..2dc9716634 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -152,6 +152,15 @@ protected virtual IList FetchReleases(IList