mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-05-08 12:43:19 +02:00
New: (Avistaz) Better error reporting for unauthorized tests
Fixes #822
This commit is contained in:
parent
a0d5421dc8
commit
a637677ec4
2 changed files with 21 additions and 0 deletions
|
|
@ -46,6 +46,11 @@ public class AvistazResponse
|
||||||
public List<AvistazRelease> Data { get; set; }
|
public List<AvistazRelease> Data { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AvistazErrorResponse
|
||||||
|
{
|
||||||
|
public string Message { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class AvistazIdInfo
|
public class AvistazIdInfo
|
||||||
{
|
{
|
||||||
public string Tmdb { get; set; }
|
public string Tmdb { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,22 @@ protected override async Task<ValidationFailure> TestConnection()
|
||||||
{
|
{
|
||||||
await GetToken();
|
await GetToken();
|
||||||
}
|
}
|
||||||
|
catch (HttpException ex)
|
||||||
|
{
|
||||||
|
if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)
|
||||||
|
{
|
||||||
|
_logger.Warn(ex, "Unauthorized request to indexer");
|
||||||
|
|
||||||
|
var jsonResponse = new HttpResponse<AvistazErrorResponse>(ex.Response);
|
||||||
|
return new ValidationFailure(string.Empty, jsonResponse.Resource?.Message ?? "Unauthorized request to indexer");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.Warn(ex, "Unable to connect to indexer");
|
||||||
|
|
||||||
|
return new ValidationFailure(string.Empty, "Unable to connect to indexer, check the log for more details");
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Warn(ex, "Unable to connect to indexer");
|
_logger.Warn(ex, "Unable to connect to indexer");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue