/// <summary>
        /// Reads to the next node in the XML document, and updates the context accordingly.
        /// If node is RequestId, reads the contents and stores in RequestId property.
        /// </summary>
        /// <returns>
        /// True if a node was read, false if there are no more elements to read./
        /// </returns>
        public override bool Read()
        {
            bool result = base.Read();

            if (this.ResponseData.StatusCode == System.Net.HttpStatusCode.OK &&
                !_checkedForErrorResponse)
            {
                // Check for top level XML element "Error".
                // Few S3 operations like CopyObject, CopyPart and CompleteMultipartUpload
                // can return an HTTP 200 response with an error element.
                if (this.IsStartElement)
                {
                    if (this.TestExpression("Error", 1))
                    {
                        var errorResponse = new Amazon.S3.Model.Internal.MarshallTransformations.S3ErrorResponseUnmarshaller().Unmarshall(this);

                        var s3Exception = new Amazon.S3.AmazonS3Exception(
                            errorResponse.Message, null, errorResponse.Type, errorResponse.Code,
                            errorResponse.RequestId, this.ResponseData.StatusCode, errorResponse.Id2, errorResponse.AmzCfId);
                        s3Exception.Region = errorResponse.Region;

                        throw s3Exception;
                    }
                    _checkedForErrorResponse = true;
                }
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Reads to the next node in the XML document, and updates the context accordingly.
        /// If node is RequestId, reads the contents and stores in RequestId property.
        /// </summary>
        /// <returns>
        /// True if a node was read, false if there are no more elements to read./
        /// </returns>
        public override bool Read()
        {
            bool result = base.Read();
            if (this.ResponseData.StatusCode == System.Net.HttpStatusCode.OK &&
                !_checkedForErrorResponse)
            {
                // Check for top level XML element "Error".
                // Few S3 operations like CopyObject, CopyPart and CompleteMultipartUpload
                // can return an HTTP 200 response with an error element.
                if (this.IsStartElement)
                {
                    if (this.TestExpression("Error", 1))
                    {
                        var errorResponse = new Amazon.S3.Model.Internal.MarshallTransformations.S3ErrorResponseUnmarshaller().Unmarshall(this);

                        var s3Exception = new Amazon.S3.AmazonS3Exception(
                            errorResponse.Message, null, errorResponse.Type, errorResponse.Code,
                            errorResponse.RequestId, this.ResponseData.StatusCode, errorResponse.Id2, errorResponse.AmzCfId);
                        s3Exception.Region = errorResponse.Region;

                        throw s3Exception;
                    }
                    _checkedForErrorResponse = true;
                }
            }
            return result;
        }