protected void ParseFault(XmlNode faultNode) { Parameters = new XmlRpcParameterArray(); if (faultNode.Name != "fault") { throw new Exception($"WARN XmlRpcResponse.ParseFault: Unexpected node name, expected \"fault\" found \"{faultNode.Name}\"."); } if (faultNode.ChildNodes.Count != 1) { throw new Exception("WARN XmlRpcResponse.ParseFault: Unexpected number of nodes in fault."); } XmlNode valueNode = faultNode.FirstChild; if (valueNode.Name != "value") { throw new Exception($"WARN XmlRpcResponse.ParseFault: Unexpected node name, expected \"value\" found \"{valueNode.Name}\"."); } if (valueNode.ChildNodes.Count != 1) { throw new Exception("WARN XmlRpcResponse.ParseFault: Unexpected number of nodes in value."); } XmlRpcValue faultValue = XmlRpcValue.FromXmlNode(valueNode.FirstChild); if (faultValue is XmlRpcStruct == false) { throw new Exception("WARN XmlRpcResponse.ParseFault: Unexpected value type."); } XmlRpcStruct fault = (XmlRpcStruct)faultValue; if (fault.Has("faultCode") == false) { throw new Exception("WARN XmlRpcResponse.ParseFault: Fault response has no faultCode."); } if (fault["faultCode"] is XmlRpcInteger == false) { throw new Exception("WARN XmlRpcResponse.ParseFault: faultCode is not an integer."); } FaultCode = ((XmlRpcInteger)fault["faultCode"]).Value; if (fault.Has("faultString") == false) { throw new Exception("WARN XmlRpcResponse.ParseFault: Fault response has no faultString."); } if (fault["faultString"] is XmlRpcString == false) { throw new Exception("WARN XmlRpcResponse.ParseFault: faultString is not a string."); } FaultString = ((XmlRpcString)fault["faultString"]).Value; }