fixup! Fixed: Better Indexer Response Handling

resp-http
bakerboy448 2 years ago
parent 05c468ea2d
commit 7e86bea85a

@ -49,21 +49,6 @@ namespace NzbDrone.Core.Indexers.Cardigann
CookiesUpdater(null, null); 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."); 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; var results = indexerResponse.Content;

@ -398,11 +398,21 @@ namespace NzbDrone.Core.Indexers
// Throw common http errors here before we try to parse // Throw common http errors here before we try to parse
if (response.HasHttpError) if (response.HasHttpError)
{ {
_logger.Warn("HTTP Error - {0}", response); _logger.Warn("HTTP Error - {0}", response);
switch (response.StatusCode)
if (response.StatusCode == HttpStatusCode.TooManyRequests)
{ {
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