1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-11 12:02:35 +02:00

Fixed error detection for SAB

This commit is contained in:
Mark McDowall 2013-11-20 22:29:26 -08:00
parent bc0bd647df
commit 8bd15612f4
3 changed files with 17 additions and 6 deletions

View File

@ -97,19 +97,19 @@ private void CheckForError(IRestResponse response)
if (response.Content.StartsWith("error", StringComparison.InvariantCultureIgnoreCase))
{
result.Status = false;
result.Status = "false";
result.Error = response.Content.Replace("error: ", "");
}
else
{
result.Status = true;
result.Status = "true";
}
result.Error = response.Content.Replace("error: ", "");
}
if (!result.Status)
if (result.Failed)
throw new ApplicationException(result.Error);
}

View File

@ -1,8 +1,19 @@
namespace NzbDrone.Core.Download.Clients.Sabnzbd
using System;
namespace NzbDrone.Core.Download.Clients.Sabnzbd
{
public class SabJsonError
{
public bool Status { get; set; }
public string Status { get; set; }
public string Error { get; set; }
public bool Failed
{
get
{
return !String.IsNullOrWhiteSpace(Status) &&
Status.Equals("false", StringComparison.InvariantCultureIgnoreCase);
}
}
}
}

View File

@ -243,7 +243,7 @@ private void CheckForError(string response)
{
var result = Json.Deserialize<SabJsonError>(response);
if (result.Status)
if (result.Failed)
throw new ApplicationException(result.Error);
}
}