internal static string FormatExceptionMessage()

in src/Microsoft.Azure.NotificationHubs/ExceptionUtility.cs [86:116]


        internal static string FormatExceptionMessage(string responseBody, HttpStatusCode code, string reasonPhrase, string trackingId)
        {
            var exceptionMessage = string.Empty;
            using(var stringReader = new StringReader(responseBody))
            using (var reader = XmlReader.Create(stringReader))
            {
                try
                {
                    reader.Read();
                    reader.ReadStartElement(RootTag);

                    reader.ReadStartElement(HttpStatusCodeTag);
                    reader.ReadString();
                    reader.ReadEndElement();

                    reader.ReadStartElement(DetailTag);
                    exceptionMessage = string.Format(CultureInfo.InvariantCulture, "{0} {1}", exceptionMessage, reader.ReadString());
                }
                catch (XmlException)
                {
                    // Ignore this exception
                }
            }

            if (string.IsNullOrEmpty(exceptionMessage))
            {
                exceptionMessage = string.Format(SRClient.TrackableHttpExceptionMessageFormat, (int)code, code.ToString(), reasonPhrase, CreateClientTrackingExceptionInfo(trackingId));
            }

            return exceptionMessage;
        }