fixup! Fixed: Better Indexer Response Handling

pull/825/head
bakerboy448 2 years ago
parent 05c468ea2d
commit 7e86bea85a

@ -49,21 +49,6 @@ namespace NzbDrone.Core.Indexers.Cardigann
CookiesUpdater(null, null);
throw new IndexerException(indexerResponse, "We are being redirected to the login page. Most likely your session expired or was killed. Try testing the indexer in the settings.");
}
// Catch common http exceptions before parsing
switch (indexerResponseStatus)
{
case HttpStatusCode.BadRequest:
case HttpStatusCode.Forbidden:
case HttpStatusCode.BadGateway:
case HttpStatusCode.ServiceUnavailable:
case HttpStatusCode.GatewayTimeout:
throw new HttpException(indexerResponse.HttpResponse);
case HttpStatusCode.Unauthorized:
throw new IndexerAuthException(indexerResponse.HttpResponse.Content.ToString());
default:
throw new IndexerException(indexerResponse, $"Unexpected response status {indexerResponseStatus} code from API request");
}
}
var results = indexerResponse.Content;

@ -398,11 +398,21 @@ namespace NzbDrone.Core.Indexers
// Throw common http errors here before we try to parse
if (response.HasHttpError)
{
_logger.Warn("HTTP Error - {0}", response);
if (response.StatusCode == HttpStatusCode.TooManyRequests)
_logger.Warn("HTTP Error - {0}", response);
switch (response.StatusCode)
{
throw new TooManyRequestsException(request.HttpRequest, response);
case HttpStatusCode.BadRequest:
case HttpStatusCode.Forbidden:
case HttpStatusCode.BadGateway:
case HttpStatusCode.ServiceUnavailable:
case HttpStatusCode.GatewayTimeout:
throw new HttpException(response);
case HttpStatusCode.TooManyRequests:
throw new TooManyRequestsException(request.HttpRequest, response);
case HttpStatusCode.Unauthorized:
throw new IndexerAuthException(response.Content.ToString());
default:
throw new HttpException(response);
}
}

Loading…
Cancel
Save