/// <summary> /// Gets the error details from an XML-formatted error stream. /// </summary> /// <param name="inputStream">The input stream.</param> /// <returns>The error details.</returns> public static StorageExtendedErrorInformation ReadFromStream(Stream inputStream) { CommonUtility.AssertNotNull("inputStream", inputStream); if (inputStream.CanSeek && inputStream.Length < 1) { return(null); } StorageExtendedErrorInformation extendedErrorInfo = new StorageExtendedErrorInformation(); try { using (XmlReader reader = XmlReader.Create(inputStream)) { reader.Read(); extendedErrorInfo.ReadXml(reader); } return(extendedErrorInfo); } catch (XmlException) { // If there is a parsing error we cannot return extended error information return(null); } }
/// <summary> /// Gets the error details from an XML-formatted error stream. /// </summary> /// <param name="inputStream">The input stream.</param> /// <returns>The error details.</returns> public static async Task <StorageExtendedErrorInformation> ReadFromStreamAsync(Stream inputStream) { CommonUtility.AssertNotNull("inputStream", inputStream); if (inputStream.CanSeek && inputStream.Length < 1) { return(null); } StorageExtendedErrorInformation extendedErrorInfo = new StorageExtendedErrorInformation(); try { XmlReaderSettings settings = new XmlReaderSettings(); settings.Async = true; using (XmlReader reader = XmlReader.Create(inputStream, settings)) { await reader.ReadAsync(); extendedErrorInfo.ReadXml(reader); } return(extendedErrorInfo); } catch (XmlException) { // If there is a parsing error we cannot return extended error information return(null); } }