Esempio n. 1
0
        private static AzureStorageErrorResponse ReadErrorResponse(string content)
        {
            AzureStorageErrorResponse response = new AzureStorageErrorResponse();

            using (XmlReader reader = XmlReader.Create(new StringReader(content)))
            {
                string currentNodeName = null;
                while (reader.Read())
                {
                    if (currentNodeName != null)
                    {
                        if (string.Equals(currentNodeName, "Code", StringComparison.OrdinalIgnoreCase))
                        {
                            response.Code = reader.Value;
                        }
                        else if (string.Equals(currentNodeName, "Message", StringComparison.OrdinalIgnoreCase))
                        {
                            response.Message = reader.Value;
                        }
                        else
                        {
                            response.Details[currentNodeName] = reader.Value;
                        }

                        currentNodeName = null;
                        continue;
                    }

                    if (reader.NodeType == XmlNodeType.Element && reader.IsStartElement() && reader.Name != "Error")
                    {
                        currentNodeName = reader.Name;
                    }
                }
            }

            return(response);
        }
Esempio n. 2
0
 public AzureStorageHttpException(AzureStorageErrorResponse error)
     : this(error.Message, error.Code, error.Message)
 {
 }