mirror of
https://github.com/Prowlarr/Prowlarr
synced 2025-12-06 08:34:28 +01:00
New: (PTP) Improve Error Handling
This commit is contained in:
parent
ae9326480e
commit
4d9982872a
2 changed files with 12 additions and 0 deletions
|
|
@ -35,6 +35,16 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
||||||
throw new RequestLimitReachedException(indexerResponse, "PTP Query Limit Reached. Please try again later.");
|
throw new RequestLimitReachedException(indexerResponse, "PTP Query Limit Reached. Please try again later.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (httpResponse.StatusCode == HttpStatusCode.TooManyRequests && indexerResponse.Content.Contains("We are not a TV indexer"))
|
||||||
|
{
|
||||||
|
throw new IndexerException(indexerResponse, "Invalid indexer request: We are not a TV indexer", HttpStatusCode.BadRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (httpResponse.StatusCode == HttpStatusCode.TooManyRequests)
|
||||||
|
{
|
||||||
|
throw new RequestLimitReachedException(indexerResponse, "PTP Request Limit Reached. Please try again later.");
|
||||||
|
}
|
||||||
|
|
||||||
throw new IndexerException(indexerResponse, $"Unexpected response status {indexerResponse.HttpResponse.StatusCode} code from indexer request");
|
throw new IndexerException(indexerResponse, $"Unexpected response status {indexerResponse.HttpResponse.StatusCode} code from indexer request");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||||
|
|
@ -115,6 +116,7 @@ private IEnumerable<IndexerRequest> GetRequest(string searchTerm, SearchCriteria
|
||||||
var request = new IndexerRequest(searchUrl, HttpAccept.Json);
|
var request = new IndexerRequest(searchUrl, HttpAccept.Json);
|
||||||
request.HttpRequest.Headers.Add("ApiUser", _settings.APIUser);
|
request.HttpRequest.Headers.Add("ApiUser", _settings.APIUser);
|
||||||
request.HttpRequest.Headers.Add("ApiKey", _settings.APIKey);
|
request.HttpRequest.Headers.Add("ApiKey", _settings.APIKey);
|
||||||
|
request.HttpRequest.SuppressHttpErrorStatusCodes = new[] { HttpStatusCode.TooManyRequests };
|
||||||
|
|
||||||
yield return request;
|
yield return request;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue