Наследование: Amazon.Runtime.AmazonServiceException
Пример #1
0
        public AmazonAutoScalingException(string message, Exception innerException) : base(message, innerException)
        {
            this.message = message;
            AmazonAutoScalingException exception = innerException as AmazonAutoScalingException;

            if (exception != null)
            {
                this.statusCode = exception.StatusCode;
                this.errorCode  = exception.ErrorCode;
                this.errorType  = exception.ErrorType;
                this.requestId  = exception.RequestId;
                this.xml        = exception.XML;
            }
        }
Пример #2
0
        /**
         * Look for additional error strings in the response and return formatted exception
         */
        private static AmazonAutoScalingException ReportAnyErrors(string responseBody, HttpStatusCode status)
        {
            AmazonAutoScalingException ex = null;

            if (responseBody != null &&
                responseBody.StartsWith("<"))
            {
                Match errorMatcherOne = Regex.Match(
                    responseBody,
                    "<RequestId>(.*)</RequestId>.*<Error><Code>(.*)</Code><Message>(.*)</Message></Error>.*(<Error>)?",
                    RegexOptions.Multiline
                    );
                Match errorMatcherTwo = Regex.Match(
                    responseBody,
                    "<Error><Code>(.*)</Code><Message>(.*)</Message></Error>.*(<Error>)?.*<RequestID>(.*)</RequestID>",
                    RegexOptions.Multiline
                    );

                if (errorMatcherOne.Success)
                {
                    string requestId = errorMatcherOne.Groups[1].Value;
                    string code      = errorMatcherOne.Groups[2].Value;
                    string message   = errorMatcherOne.Groups[3].Value;

                    ex = new AmazonAutoScalingException(message, status, code, "Unknown", requestId, responseBody);
                }
                else if (errorMatcherTwo.Success)
                {
                    string code      = errorMatcherTwo.Groups[1].Value;
                    string message   = errorMatcherTwo.Groups[2].Value;
                    string requestId = errorMatcherTwo.Groups[4].Value;

                    ex = new AmazonAutoScalingException(message, status, code, "Unknown", requestId, responseBody);
                }
                else
                {
                    ex = new AmazonAutoScalingException("Internal Error", status);
                }
            }
            else
            {
                ex = new AmazonAutoScalingException("Internal Error", status);
            }
            return(ex);
        }