private void CheckForError(IRestResponse response) { if (response.ResponseStatus != ResponseStatus.Completed) { throw new DownloadClientException("Unable to connect to SABnzbd, please check your settings", response.ErrorException); } SabnzbdJsonError result; if (!Json.TryDeserialize <SabnzbdJsonError>(response.Content, out result)) { //Handle plain text responses from SAB result = new SabnzbdJsonError(); if (response.Content.StartsWith("error", StringComparison.InvariantCultureIgnoreCase)) { result.Status = "false"; result.Error = response.Content.Replace("error: ", ""); } else { result.Status = "true"; } result.Error = response.Content.Replace("error: ", ""); } if (result.Failed) { throw new DownloadClientException("Error response received from SABnzbd: {0}", result.Error); } }
private void CheckForError(HttpResponse response) { SabnzbdJsonError result; if (!Json.TryDeserialize<SabnzbdJsonError>(response.Content, out result)) { //Handle plain text responses from SAB result = new SabnzbdJsonError(); if (response.Content.StartsWith("error", StringComparison.InvariantCultureIgnoreCase)) { result.Status = "false"; result.Error = response.Content.Replace("error: ", ""); } else { result.Status = "true"; } result.Error = response.Content.Replace("error: ", ""); } if (result.Failed) { throw new DownloadClientException("Error response received from SABnzbd: {0}", result.Error); } }
private void CheckForError(IRestResponse response) { if (response.ResponseStatus != ResponseStatus.Completed) { throw new DownloadClientException("Unable to connect to SABnzbd, please check your settings", response.ErrorException); } SabnzbdJsonError result; if (!Json.TryDeserialize<SabnzbdJsonError>(response.Content, out result)) { //Handle plain text responses from SAB result = new SabnzbdJsonError(); if (response.Content.StartsWith("error", StringComparison.InvariantCultureIgnoreCase)) { result.Status = "false"; result.Error = response.Content.Replace("error: ", ""); } else { result.Status = "true"; } result.Error = response.Content.Replace("error: ", ""); } if (result.Failed) throw new DownloadClientException("Error response received from SABnzbd: {0}", result.Error); }