Exemplo n.º 1
0
        internal ClusterErrorStatus DeserializeClusterError(XElement resource)
        {
            resource.ArgumentNotNull("resource");
            var operationStatusElement = resource.Element(OperationStatusElementName);

            if (operationStatusElement == null)
            {
                return(null);
            }

            string             errorMessage;
            ClusterErrorStatus clusterErrorStatus = null;
            var errorElement         = operationStatusElement.Element(ErrorElementName);
            var extendedErrorElement = this.ExtractResourceOutputStringValue(resource, ExtendedErrorElementName);

            if (errorElement != null)
            {
                var errorType = this.GetStringValue(operationStatusElement, TypeElementName);
                var httpCode  = int.Parse(this.GetStringValue(errorElement, HttpCodeElementName), CultureInfo.InvariantCulture);
                errorMessage       = this.GetStringValue(errorElement, MessageElementName);
                clusterErrorStatus = new ClusterErrorStatus(httpCode, errorMessage, errorType);
            }

            if (extendedErrorElement.IsNotNullOrEmpty())
            {
                if (clusterErrorStatus == null)
                {
                    clusterErrorStatus = new ClusterErrorStatus();
                }

                clusterErrorStatus.Message = extendedErrorElement;
            }

            return(clusterErrorStatus);
        }
Exemplo n.º 2
0
        internal ClusterErrorStatus DeserializeClusterError(XElement resource)
        {
            resource.ArgumentNotNull("resource");
            var operationStatusElement = resource.Element(OperationStatusElementName);
            if (operationStatusElement == null)
            {
                return null;
            }

            string errorMessage;
            ClusterErrorStatus clusterErrorStatus = null;
            var errorElement = operationStatusElement.Element(ErrorElementName);
            var extendedErrorElement = this.ExtractResourceOutputStringValue(resource, ExtendedErrorElementName);

            if (errorElement != null)
            {
                var errorType = this.GetStringValue(operationStatusElement, TypeElementName);
                var httpCode = int.Parse(this.GetStringValue(errorElement, HttpCodeElementName), CultureInfo.InvariantCulture);
                errorMessage = this.GetStringValue(errorElement, MessageElementName);
                clusterErrorStatus = new ClusterErrorStatus(httpCode, errorMessage, errorType);
            }

            if (extendedErrorElement.IsNotNullOrEmpty())
            {
                if (clusterErrorStatus == null)
                {
                    clusterErrorStatus = new ClusterErrorStatus();
                }

                clusterErrorStatus.Message = extendedErrorElement;
            }

            return clusterErrorStatus;
        }