Inheritance: Amazon.Runtime.AmazonServiceException
        public AmazonElasticMapReduceException(string message, Exception innerException) : base(message, innerException)
        {
            this.message = message;
            AmazonElasticMapReduceException exception = innerException as AmazonElasticMapReduceException;

            if (exception != null)
            {
                this.statusCode = exception.StatusCode;
                this.errorCode  = exception.ErrorCode;
                this.errorType  = exception.ErrorType;
                this.requestId  = exception.RequestId;
                this.xml        = exception.XML;
            }
        }
Ejemplo n.º 2
0
        /**
         * Look for additional error strings in the response and return formatted exception
         */
        private static AmazonElasticMapReduceException ReportAnyErrors(string responseBody, HttpStatusCode status)
        {
            AmazonElasticMapReduceException 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 AmazonElasticMapReduceException(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 AmazonElasticMapReduceException(message, status, code, "Unknown", requestId, responseBody);
                }
                else
                {
                    ex = new AmazonElasticMapReduceException("Internal Error", status);
                }
            }
            else
            {
                ex = new AmazonElasticMapReduceException("Internal Error", status);
            }
            return(ex);
        }