Fixed error detection for SAB

pull/38/merge
Mark McDowall 11 years ago
parent bc0bd647df
commit 8bd15612f4

@ -97,19 +97,19 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
if (response.Content.StartsWith("error", StringComparison.InvariantCultureIgnoreCase)) if (response.Content.StartsWith("error", StringComparison.InvariantCultureIgnoreCase))
{ {
result.Status = false; result.Status = "false";
result.Error = response.Content.Replace("error: ", ""); result.Error = response.Content.Replace("error: ", "");
} }
else else
{ {
result.Status = true; result.Status = "true";
} }
result.Error = response.Content.Replace("error: ", ""); result.Error = response.Content.Replace("error: ", "");
} }
if (!result.Status) if (result.Failed)
throw new ApplicationException(result.Error); throw new ApplicationException(result.Error);
} }

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

@ -243,7 +243,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
{ {
var result = Json.Deserialize<SabJsonError>(response); var result = Json.Deserialize<SabJsonError>(response);
if (result.Status) if (result.Failed)
throw new ApplicationException(result.Error); throw new ApplicationException(result.Error);
} }
} }

Loading…
Cancel
Save