/// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("BatchModifyClusterSnapshotsLimitExceededFault"))
                    {
                        return(BatchModifyClusterSnapshotsLimitExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidRetentionPeriodFault"))
                    {
                        return(InvalidRetentionPeriodExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonRedshiftException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDenied"))
                    {
                        return(AccessDeniedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchStreamingDistribution"))
                    {
                        return(NoSuchStreamingDistributionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonCloudFrontException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidStateTransition"))
                    {
                        return(InvalidStateTransitionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ConditionalCheckFailed"))
                    {
                        return(OperationStatusCheckFailedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonCloudFormationException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("BucketAlreadyExists"))
                    {
                        return(BucketAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("BucketAlreadyOwnedByYou"))
                    {
                        return(BucketAlreadyOwnedByYouExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonS3ControlException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#5
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchEntity"))
                    {
                        return(NoSuchEntityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ServiceFailure"))
                    {
                        return(ServiceFailureExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonIdentityManagementServiceException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidMessageContents"))
                    {
                        return(InvalidMessageContentsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AWS.SimpleQueueService.UnsupportedOperation"))
                    {
                        return(UnsupportedOperationExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonSQSException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#7
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InsufficientPrivilegesException"))
                    {
                        return(InsufficientPrivilegesExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyEnvironmentsException"))
                    {
                        return(TooManyEnvironmentsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonElasticBeanstalkException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#8
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ConfigurationSetDoesNotExist"))
                    {
                        return(ConfigurationSetDoesNotExistExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidDeliveryOptions"))
                    {
                        return(InvalidDeliveryOptionsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonSimpleEmailServiceException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#9
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidInput"))
                    {
                        return(InvalidInputExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchQueryLoggingConfig"))
                    {
                        return(NoSuchQueryLoggingConfigExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonRoute53Exception(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#10
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidTagFault"))
                    {
                        return(InvalidTagExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("SubscriptionNotFound"))
                    {
                        return(SubscriptionNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonRedshiftException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#11
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InternalServiceError"))
                    {
                        return(InternalServiceExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterValue"))
                    {
                        return(InvalidParameterValueExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonCloudWatchException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#12
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceContention"))
                    {
                        return(ResourceContentionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ScalingActivityInProgress"))
                    {
                        return(ScalingActivityInProgressExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonAutoScalingException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("OperationNotPermitted"))
                    {
                        return(OperationNotPermittedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("RuleNotFound"))
                    {
                        return(RuleNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonElasticLoadBalancingV2Exception(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("CustomAvailabilityZoneNotFound"))
                    {
                        return(CustomAvailabilityZoneNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InstallationMediaAlreadyExists"))
                    {
                        return(InstallationMediaAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonRDSException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#15
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDenied"))
                    {
                        return(AccessDeniedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("FieldLevelEncryptionProfileAlreadyExists"))
                    {
                        return(FieldLevelEncryptionProfileAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("FieldLevelEncryptionProfileSizeExceeded"))
                    {
                        return(FieldLevelEncryptionProfileSizeExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("IllegalUpdate"))
                    {
                        return(IllegalUpdateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InconsistentQuantities"))
                    {
                        return(InconsistentQuantitiesExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidArgument"))
                    {
                        return(InvalidArgumentExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidIfMatchVersion"))
                    {
                        return(InvalidIfMatchVersionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchFieldLevelEncryptionProfile"))
                    {
                        return(NoSuchFieldLevelEncryptionProfileExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchPublicKey"))
                    {
                        return(NoSuchPublicKeyExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("PreconditionFailed"))
                    {
                        return(PreconditionFailedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyFieldLevelEncryptionEncryptionEntities"))
                    {
                        return(TooManyFieldLevelEncryptionEncryptionEntitiesExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyFieldLevelEncryptionFieldPatterns"))
                    {
                        return(TooManyFieldLevelEncryptionFieldPatternsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonCloudFrontException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#16
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterQuotaForCustomerExceeded"))
                    {
                        return(ClusterQuotaForCustomerExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InsufficientCacheClusterCapacity"))
                    {
                        return(InsufficientCacheClusterCapacityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidCacheClusterState"))
                    {
                        return(InvalidCacheClusterStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidKMSKeyFault"))
                    {
                        return(InvalidKMSKeyExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterCombination"))
                    {
                        return(InvalidParameterCombinationExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterValue"))
                    {
                        return(InvalidParameterValueExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidReplicationGroupState"))
                    {
                        return(InvalidReplicationGroupStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidVPCNetworkStateFault"))
                    {
                        return(InvalidVPCNetworkStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NodeGroupsPerReplicationGroupQuotaExceeded"))
                    {
                        return(NodeGroupsPerReplicationGroupQuotaExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NodeQuotaForCustomerExceeded"))
                    {
                        return(NodeQuotaForCustomerExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoOperationFault"))
                    {
                        return(NoOperationExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ReplicationGroupNotFoundFault"))
                    {
                        return(ReplicationGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonElastiCacheException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#17
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("CacheClusterNotFound"))
                    {
                        return(CacheClusterNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("CacheParameterGroupNotFound"))
                    {
                        return(CacheParameterGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("CacheSecurityGroupNotFound"))
                    {
                        return(CacheSecurityGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("CacheSubnetGroupNotFoundFault"))
                    {
                        return(CacheSubnetGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidARN"))
                    {
                        return(InvalidARNExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidReplicationGroupState"))
                    {
                        return(InvalidReplicationGroupStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ReplicationGroupNotFoundFault"))
                    {
                        return(ReplicationGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ReservedCacheNodeNotFound"))
                    {
                        return(ReservedCacheNodeNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("SnapshotNotFoundFault"))
                    {
                        return(SnapshotNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TagQuotaPerResourceExceeded"))
                    {
                        return(TagQuotaPerResourceExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("UserGroupNotFound"))
                    {
                        return(UserGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("UserNotFound"))
                    {
                        return(UserNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonElastiCacheException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("BucketPermissionException"))
                    {
                        return(BucketPermissionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("CanceledJobIdException"))
                    {
                        return(CanceledJobIdExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ExpiredJobIdException"))
                    {
                        return(ExpiredJobIdExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidAccessKeyIdException"))
                    {
                        return(InvalidAccessKeyIdExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidAddressException"))
                    {
                        return(InvalidAddressExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidCustomsException"))
                    {
                        return(InvalidCustomsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidFileSystemException"))
                    {
                        return(InvalidFileSystemExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidJobIdException"))
                    {
                        return(InvalidJobIdExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidManifestFieldException"))
                    {
                        return(InvalidManifestFieldExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterException"))
                    {
                        return(InvalidParameterExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidVersionException"))
                    {
                        return(InvalidVersionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("MalformedManifestException"))
                    {
                        return(MalformedManifestExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("MissingCustomsException"))
                    {
                        return(MissingCustomsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("MissingManifestFieldException"))
                    {
                        return(MissingManifestFieldExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("MissingParameterException"))
                    {
                        return(MissingParameterExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("MultipleRegionsException"))
                    {
                        return(MultipleRegionsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchBucketException"))
                    {
                        return(NoSuchBucketExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("UnableToUpdateJobIdException"))
                    {
                        return(UnableToUpdateJobIdExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonImportExportException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#19
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AllocationIdNotFound"))
                    {
                        return(AllocationIdNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AvailabilityZoneNotSupported"))
                    {
                        return(AvailabilityZoneNotSupportedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DuplicateLoadBalancerName"))
                    {
                        return(DuplicateLoadBalancerNameExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DuplicateTagKeys"))
                    {
                        return(DuplicateTagKeysExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidConfigurationRequest"))
                    {
                        return(InvalidConfigurationRequestExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidScheme"))
                    {
                        return(InvalidSchemeExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidSecurityGroup"))
                    {
                        return(InvalidSecurityGroupExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidSubnet"))
                    {
                        return(InvalidSubnetExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("OperationNotPermitted"))
                    {
                        return(OperationNotPermittedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceInUse"))
                    {
                        return(ResourceInUseExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("SubnetNotFound"))
                    {
                        return(SubnetNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyLoadBalancers"))
                    {
                        return(TooManyLoadBalancersExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyTags"))
                    {
                        return(TooManyTagsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonElasticLoadBalancingV2Exception(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDenied"))
                    {
                        return(AccessDeniedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("CNAMEAlreadyExists"))
                    {
                        return(CNAMEAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DistributionAlreadyExists"))
                    {
                        return(DistributionAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("IllegalFieldLevelEncryptionConfigAssociationWithCacheBehavior"))
                    {
                        return(IllegalFieldLevelEncryptionConfigAssociationWithCacheBehaviorExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InconsistentQuantities"))
                    {
                        return(InconsistentQuantitiesExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidArgument"))
                    {
                        return(InvalidArgumentExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidDefaultRootObject"))
                    {
                        return(InvalidDefaultRootObjectExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidErrorCode"))
                    {
                        return(InvalidErrorCodeExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidForwardCookies"))
                    {
                        return(InvalidForwardCookiesExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidGeoRestrictionParameter"))
                    {
                        return(InvalidGeoRestrictionParameterExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidHeadersForS3Origin"))
                    {
                        return(InvalidHeadersForS3OriginExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidLambdaFunctionAssociation"))
                    {
                        return(InvalidLambdaFunctionAssociationExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidLocationCode"))
                    {
                        return(InvalidLocationCodeExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidMinimumProtocolVersion"))
                    {
                        return(InvalidMinimumProtocolVersionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidOriginAccessIdentity"))
                    {
                        return(InvalidOriginAccessIdentityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidOrigin"))
                    {
                        return(InvalidOriginExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidOriginKeepaliveTimeout"))
                    {
                        return(InvalidOriginKeepaliveTimeoutExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidOriginReadTimeout"))
                    {
                        return(InvalidOriginReadTimeoutExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidProtocolSettings"))
                    {
                        return(InvalidProtocolSettingsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidQueryStringParameters"))
                    {
                        return(InvalidQueryStringParametersExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidRelativePath"))
                    {
                        return(InvalidRelativePathExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidRequiredProtocol"))
                    {
                        return(InvalidRequiredProtocolExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidResponseCode"))
                    {
                        return(InvalidResponseCodeExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidTagging"))
                    {
                        return(InvalidTaggingExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidTTLOrder"))
                    {
                        return(InvalidTTLOrderExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidViewerCertificate"))
                    {
                        return(InvalidViewerCertificateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidWebACLId"))
                    {
                        return(InvalidWebACLIdExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("MissingBody"))
                    {
                        return(MissingBodyExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchCachePolicy"))
                    {
                        return(NoSuchCachePolicyExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchFieldLevelEncryptionConfig"))
                    {
                        return(NoSuchFieldLevelEncryptionConfigExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchOrigin"))
                    {
                        return(NoSuchOriginExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchOriginRequestPolicy"))
                    {
                        return(NoSuchOriginRequestPolicyExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyCacheBehaviors"))
                    {
                        return(TooManyCacheBehaviorsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyCertificates"))
                    {
                        return(TooManyCertificatesExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyCookieNamesInWhiteList"))
                    {
                        return(TooManyCookieNamesInWhiteListExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyDistributionCNAMEs"))
                    {
                        return(TooManyDistributionCNAMEsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyDistributionsAssociatedToCachePolicy"))
                    {
                        return(TooManyDistributionsAssociatedToCachePolicyExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyDistributionsAssociatedToFieldLevelEncryptionConfig"))
                    {
                        return(TooManyDistributionsAssociatedToFieldLevelEncryptionConfigExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyDistributionsAssociatedToOriginRequestPolicy"))
                    {
                        return(TooManyDistributionsAssociatedToOriginRequestPolicyExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyDistributions"))
                    {
                        return(TooManyDistributionsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyDistributionsWithLambdaAssociations"))
                    {
                        return(TooManyDistributionsWithLambdaAssociationsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyDistributionsWithSingleFunctionARN"))
                    {
                        return(TooManyDistributionsWithSingleFunctionARNExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyHeadersInForwardedValues"))
                    {
                        return(TooManyHeadersInForwardedValuesExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyLambdaFunctionAssociations"))
                    {
                        return(TooManyLambdaFunctionAssociationsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyOriginCustomHeaders"))
                    {
                        return(TooManyOriginCustomHeadersExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyOriginGroupsPerDistribution"))
                    {
                        return(TooManyOriginGroupsPerDistributionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyOrigins"))
                    {
                        return(TooManyOriginsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyQueryStringParameters"))
                    {
                        return(TooManyQueryStringParametersExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyTrustedSigners"))
                    {
                        return(TooManyTrustedSignersExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TrustedSignerDoesNotExist"))
                    {
                        return(TrustedSignerDoesNotExistExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonCloudFrontException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AuthorizationNotFound"))
                    {
                        return(AuthorizationNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("BackupPolicyNotFoundFault"))
                    {
                        return(BackupPolicyNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBInstanceAlreadyExists"))
                    {
                        return(DBInstanceAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBParameterGroupNotFound"))
                    {
                        return(DBParameterGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBSecurityGroupNotFound"))
                    {
                        return(DBSecurityGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBSubnetGroupDoesNotCoverEnoughAZs"))
                    {
                        return(DBSubnetGroupDoesNotCoverEnoughAZsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBSubnetGroupNotFoundFault"))
                    {
                        return(DBSubnetGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InstanceQuotaExceeded"))
                    {
                        return(InstanceQuotaExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InsufficientDBInstanceCapacity"))
                    {
                        return(InsufficientDBInstanceCapacityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidS3BucketFault"))
                    {
                        return(InvalidS3BucketExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidSubnet"))
                    {
                        return(InvalidSubnetExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidVPCNetworkStateFault"))
                    {
                        return(InvalidVPCNetworkStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("KMSKeyNotAccessibleFault"))
                    {
                        return(KMSKeyNotAccessibleExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("OptionGroupNotFoundFault"))
                    {
                        return(OptionGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ProvisionedIopsNotAvailableInAZFault"))
                    {
                        return(ProvisionedIopsNotAvailableInAZExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("StorageQuotaExceeded"))
                    {
                        return(StorageQuotaExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("StorageTypeNotSupported"))
                    {
                        return(StorageTypeNotSupportedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonRDSException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ALPNPolicyNotFound"))
                    {
                        return(ALPNPolicyNotSupportedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("CertificateNotFound"))
                    {
                        return(CertificateNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DuplicateListener"))
                    {
                        return(DuplicateListenerExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("IncompatibleProtocols"))
                    {
                        return(IncompatibleProtocolsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidConfigurationRequest"))
                    {
                        return(InvalidConfigurationRequestExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidLoadBalancerAction"))
                    {
                        return(InvalidLoadBalancerActionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("LoadBalancerNotFound"))
                    {
                        return(LoadBalancerNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("SSLPolicyNotFound"))
                    {
                        return(SSLPolicyNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TargetGroupAssociationLimit"))
                    {
                        return(TargetGroupAssociationLimitExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TargetGroupNotFound"))
                    {
                        return(TargetGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyActions"))
                    {
                        return(TooManyActionsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyCertificates"))
                    {
                        return(TooManyCertificatesExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyListeners"))
                    {
                        return(TooManyListenersExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyRegistrationsForTargetId"))
                    {
                        return(TooManyRegistrationsForTargetIdExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyTargets"))
                    {
                        return(TooManyTargetsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyUniqueTargetGroupsPerLoadBalancer"))
                    {
                        return(TooManyUniqueTargetGroupsPerLoadBalancerExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("UnsupportedProtocol"))
                    {
                        return(UnsupportedProtocolExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonElasticLoadBalancingV2Exception(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#23
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AuthorizationNotFound"))
                    {
                        return(AuthorizationNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("CertificateNotFound"))
                    {
                        return(CertificateNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBInstanceAlreadyExists"))
                    {
                        return(DBInstanceAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBInstanceNotFound"))
                    {
                        return(DBInstanceNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBParameterGroupNotFound"))
                    {
                        return(DBParameterGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBSecurityGroupNotFound"))
                    {
                        return(DBSecurityGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBUpgradeDependencyFailure"))
                    {
                        return(DBUpgradeDependencyFailureExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InsufficientDBInstanceCapacity"))
                    {
                        return(InsufficientDBInstanceCapacityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidDBInstanceState"))
                    {
                        return(InvalidDBInstanceStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidDBSecurityGroupState"))
                    {
                        return(InvalidDBSecurityGroupStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidVPCNetworkStateFault"))
                    {
                        return(InvalidVPCNetworkStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("StorageQuotaExceeded"))
                    {
                        return(StorageQuotaExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("StorageTypeNotSupported"))
                    {
                        return(StorageTypeNotSupportedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonDocDBException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#24
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterAlreadyExists"))
                    {
                        return(ClusterAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterNotFound"))
                    {
                        return(ClusterNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterParameterGroupNotFound"))
                    {
                        return(ClusterParameterGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterSecurityGroupNotFound"))
                    {
                        return(ClusterSecurityGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DependentServiceRequestThrottlingFault"))
                    {
                        return(DependentServiceRequestThrottlingExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("HsmClientCertificateNotFoundFault"))
                    {
                        return(HsmClientCertificateNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("HsmConfigurationNotFoundFault"))
                    {
                        return(HsmConfigurationNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InsufficientClusterCapacity"))
                    {
                        return(InsufficientClusterCapacityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidClusterSecurityGroupState"))
                    {
                        return(InvalidClusterSecurityGroupStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidClusterState"))
                    {
                        return(InvalidClusterStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidClusterTrack"))
                    {
                        return(InvalidClusterTrackExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidElasticIpFault"))
                    {
                        return(InvalidElasticIpExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidRetentionPeriodFault"))
                    {
                        return(InvalidRetentionPeriodExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("LimitExceededFault"))
                    {
                        return(LimitExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NumberOfNodesPerClusterLimitExceeded"))
                    {
                        return(NumberOfNodesPerClusterLimitExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NumberOfNodesQuotaExceeded"))
                    {
                        return(NumberOfNodesQuotaExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TableLimitExceeded"))
                    {
                        return(TableLimitExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("UnauthorizedOperation"))
                    {
                        return(UnauthorizedOperationExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("UnsupportedOptionFault"))
                    {
                        return(UnsupportedOptionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonRedshiftException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDenied"))
                    {
                        return(AccessDeniedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("CNAMEAlreadyExists"))
                    {
                        return(CNAMEAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("IllegalUpdate"))
                    {
                        return(IllegalUpdateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InconsistentQuantities"))
                    {
                        return(InconsistentQuantitiesExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidArgument"))
                    {
                        return(InvalidArgumentExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidIfMatchVersion"))
                    {
                        return(InvalidIfMatchVersionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidOriginAccessIdentity"))
                    {
                        return(InvalidOriginAccessIdentityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("MissingBody"))
                    {
                        return(MissingBodyExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchStreamingDistribution"))
                    {
                        return(NoSuchStreamingDistributionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("PreconditionFailed"))
                    {
                        return(PreconditionFailedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyStreamingDistributionCNAMEs"))
                    {
                        return(TooManyStreamingDistributionCNAMEsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyTrustedSigners"))
                    {
                        return(TooManyTrustedSignersExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TrustedSignerDoesNotExist"))
                    {
                        return(TrustedSignerDoesNotExistExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonCloudFrontException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>  
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
            errorResponse.InnerException = innerException;
            errorResponse.StatusCode = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
            using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
            {
                if (errorResponse.Code != null && errorResponse.Code.Equals("AccessToSnapshotDenied"))
                {
                    return AccessToSnapshotDeniedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterAlreadyExists"))
                {
                    return ClusterAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterParameterGroupNotFound"))
                {
                    return ClusterParameterGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterQuotaExceeded"))
                {
                    return ClusterQuotaExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterSecurityGroupNotFound"))
                {
                    return ClusterSecurityGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterSnapshotNotFound"))
                {
                    return ClusterSnapshotNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterSubnetGroupNotFoundFault"))
                {
                    return ClusterSubnetGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("DependentServiceRequestThrottlingFault"))
                {
                    return DependentServiceRequestThrottlingExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("HsmClientCertificateNotFoundFault"))
                {
                    return HsmClientCertificateNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("HsmConfigurationNotFoundFault"))
                {
                    return HsmConfigurationNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("InsufficientClusterCapacity"))
                {
                    return InsufficientClusterCapacityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidClusterSnapshotState"))
                {
                    return InvalidClusterSnapshotStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidClusterSubnetGroupStateFault"))
                {
                    return InvalidClusterSubnetGroupStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidClusterTrack"))
                {
                    return InvalidClusterTrackExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidElasticIpFault"))
                {
                    return InvalidElasticIpExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidRestore"))
                {
                    return InvalidRestoreExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidSubnet"))
                {
                    return InvalidSubnetExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidTagFault"))
                {
                    return InvalidTagExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidVPCNetworkStateFault"))
                {
                    return InvalidVPCNetworkStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("LimitExceededFault"))
                {
                    return LimitExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("NumberOfNodesPerClusterLimitExceeded"))
                {
                    return NumberOfNodesPerClusterLimitExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("NumberOfNodesQuotaExceeded"))
                {
                    return NumberOfNodesQuotaExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("SnapshotScheduleNotFound"))
                {
                    return SnapshotScheduleNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("TagLimitExceededFault"))
                {
                    return TagLimitExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
                if (errorResponse.Code != null && errorResponse.Code.Equals("UnauthorizedOperation"))
                {
                    return UnauthorizedOperationExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
                }
            }
            return new AmazonRedshiftException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
        }
示例#27
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AuthorizationError"))
                    {
                        return(AuthorizationErrorExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("EndpointDisabled"))
                    {
                        return(EndpointDisabledExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InternalError"))
                    {
                        return(InternalErrorExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameter"))
                    {
                        return(InvalidParameterExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ParameterValueInvalid"))
                    {
                        return(InvalidParameterValueExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidSecurity"))
                    {
                        return(InvalidSecurityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("KMSAccessDenied"))
                    {
                        return(KMSAccessDeniedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("KMSDisabled"))
                    {
                        return(KMSDisabledExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("KMSInvalidState"))
                    {
                        return(KMSInvalidStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("KMSNotFound"))
                    {
                        return(KMSNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("KMSOptInRequired"))
                    {
                        return(KMSOptInRequiredExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("KMSThrottling"))
                    {
                        return(KMSThrottlingExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NotFound"))
                    {
                        return(NotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("PlatformApplicationDisabled"))
                    {
                        return(PlatformApplicationDisabledExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonSimpleNotificationServiceException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBClusterAlreadyExistsFault"))
                    {
                        return(DBClusterAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBClusterNotFoundFault"))
                    {
                        return(DBClusterNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBClusterParameterGroupNotFound"))
                    {
                        return(DBClusterParameterGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBSubnetGroupNotFoundFault"))
                    {
                        return(DBSubnetGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DomainNotFoundFault"))
                    {
                        return(DomainNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidDBClusterStateFault"))
                    {
                        return(InvalidDBClusterStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidDBInstanceState"))
                    {
                        return(InvalidDBInstanceStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidDBSecurityGroupState"))
                    {
                        return(InvalidDBSecurityGroupStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidDBSubnetGroupStateFault"))
                    {
                        return(InvalidDBSubnetGroupStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidSubnet"))
                    {
                        return(InvalidSubnetExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidVPCNetworkStateFault"))
                    {
                        return(InvalidVPCNetworkStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("StorageQuotaExceeded"))
                    {
                        return(StorageQuotaExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonRDSException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBClusterAlreadyExistsFault"))
                    {
                        return(DBClusterAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBClusterQuotaExceededFault"))
                    {
                        return(DBClusterQuotaExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBClusterSnapshotNotFoundFault"))
                    {
                        return(DBClusterSnapshotNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBSnapshotNotFound"))
                    {
                        return(DBSnapshotNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DBSubnetGroupNotFoundFault"))
                    {
                        return(DBSubnetGroupNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InsufficientDBClusterCapacityFault"))
                    {
                        return(InsufficientDBClusterCapacityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InsufficientStorageClusterCapacity"))
                    {
                        return(InsufficientStorageClusterCapacityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidDBClusterSnapshotStateFault"))
                    {
                        return(InvalidDBClusterSnapshotStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidDBSnapshotState"))
                    {
                        return(InvalidDBSnapshotStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidRestoreFault"))
                    {
                        return(InvalidRestoreExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidSubnet"))
                    {
                        return(InvalidSubnetExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidVPCNetworkStateFault"))
                    {
                        return(InvalidVPCNetworkStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("KMSKeyNotAccessibleFault"))
                    {
                        return(KMSKeyNotAccessibleExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("StorageQuotaExceeded"))
                    {
                        return(StorageQuotaExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonDocDBException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
示例#30
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ClusterNotFound"))
                    {
                        return(ClusterNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("DependentServiceUnavailableFault"))
                    {
                        return(DependentServiceUnavailableExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InsufficientClusterCapacity"))
                    {
                        return(InsufficientClusterCapacityExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidClusterState"))
                    {
                        return(InvalidClusterStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidReservedNodeState"))
                    {
                        return(InvalidReservedNodeStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("LimitExceededFault"))
                    {
                        return(LimitExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NumberOfNodesPerClusterLimitExceeded"))
                    {
                        return(NumberOfNodesPerClusterLimitExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NumberOfNodesQuotaExceeded"))
                    {
                        return(NumberOfNodesQuotaExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ReservedNodeAlreadyExists"))
                    {
                        return(ReservedNodeAlreadyExistsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ReservedNodeAlreadyMigrated"))
                    {
                        return(ReservedNodeAlreadyMigratedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ReservedNodeNotFound"))
                    {
                        return(ReservedNodeNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ReservedNodeOfferingNotFound"))
                    {
                        return(ReservedNodeOfferingNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("UnauthorizedOperation"))
                    {
                        return(UnauthorizedOperationExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("UnsupportedOperation"))
                    {
                        return(UnsupportedOperationExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("UnsupportedOptionFault"))
                    {
                        return(UnsupportedOptionExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonRedshiftException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }