private void CheckResponse(IRestResponse response) { if (response == null) { throw new BugzillaException("Null response from Bugzilla."); } XDocument responseXml; try { responseXml = XDocument.Parse(response.Content); } catch (Exception) { throw new BugzillaException("Invalid bugzilla address " + response.ResponseUri + "."); } var members = responseXml.Descendants("member"); string faultCode = String.Empty; string faultString = String.Empty; foreach (var member in members) { var name = member.Element("name"); if (name == null) { continue; } if (name.Value == "faultCode") { var value = member.Element("value"); if (value != null) { faultCode = value.Value; } } if (name.Value == "faultString") { var value = member.Element("value"); if (value != null) { faultString = value.Value; } } } switch (faultCode) { case "": break; case "300": case "301": case "305": case "50": case "410": ClearCookieFile(); throw new BugzillaAuthenticationException(); default: var e = new BugzillaException("A Bugzilla error occured. Code: " + faultCode + ". Message: " + faultString); e.Data.Add("Error details", response.Content); throw e; } ProcessResponseCookies(response); }
private void CheckResponse(IRestResponse response) { if (response == null) { throw new BugzillaException("Null response from Bugzilla."); } XDocument responseXml; try { responseXml = XDocument.Parse(response.Content); } catch (Exception) { throw new BugzillaException("Invalid bugzilla address " + response.ResponseUri + "."); } var members = responseXml.Descendants("member"); string faultCode = String.Empty; string faultString = String.Empty; foreach (var member in members) { var name = member.Element("name"); if (name == null) continue; if (name.Value == "faultCode") { var value = member.Element("value"); if (value != null) { faultCode = value.Value; } } if (name.Value == "faultString") { var value = member.Element("value"); if (value != null) { faultString = value.Value; } } } switch (faultCode) { case "": break; case "300": case "301": case "305": case "50": case "410": ClearCookieFile(); throw new BugzillaAuthenticationException(); default: var e = new BugzillaException("A Bugzilla error occured. Code: " + faultCode + ". Message: " + faultString); e.Data.Add("Error details", response.Content); throw e; } ProcessResponseCookies(response); }