Пример #1
0
        internal static MiteException CreateFromResponse(string response, Exception innerException)
        {
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(response);

            MiteException miteException = new MiteException();

            XmlNodeList errorNodes = xmlDocument.SelectNodes("/errors/error");

            foreach (XmlNode errorNode in errorNodes)
            {
               MiteError miteError = new MiteError(errorNode.InnerText);
               XmlAttribute propertyAttribute =  errorNode.Attributes["on"];

                if (propertyAttribute != null)
                {
                    miteError.Property = propertyAttribute.Value;
                }

                miteException.Errors.Add(miteError);
            }

            return miteException;
        }
Пример #2
0
        internal static MiteException CreateFromResponse(string response, Exception innerException)
        {
            MiteException miteException;

            if (response.StartsWith(@"<?xml version=""1.0"" encoding=""UTF-8""?>"))
            {
                miteException = new MiteException(innerException.Message, innerException);

                XmlDocument xmlDocument = new XmlDocument();

                xmlDocument.LoadXml(response);

                XmlNodeList errorNodes = xmlDocument.SelectNodes("/errors/error");

                foreach (XmlNode errorNode in errorNodes)
                {
                    MiteError miteError = new MiteError(errorNode.InnerText);
                    XmlAttribute propertyAttribute = errorNode.Attributes["on"];

                    if (propertyAttribute != null)
                    {
                        miteError.Property = propertyAttribute.Value;
                    }

                    miteException.Errors.Add(miteError);
                }
            }
            else
            {
                miteException = new MiteException(response, innerException);
            }
            
            return miteException;
        }