コード例 #1
0
 /// <summary>
 /// Constructs MarketplaceWebServiceProductsException with message and wrapped exception
 /// </summary>
 /// <param name="message">Overview of error</param>
 /// <param name="t">Wrapped exception</param>
 public MarketplaceWebServiceProductsException(String message, Exception t) : base(message, t)
 {
     this.message = message;
     if (t is MarketplaceWebServiceProductsException)
     {
         MarketplaceWebServiceProductsException ex = (MarketplaceWebServiceProductsException)t;
         this.statusCode             = ex.StatusCode;
         this.errorCode              = ex.ErrorCode;
         this.errorType              = ex.ErrorType;
         this.requestId              = ex.RequestId;
         this.xml                    = ex.XML;
         this.responseHeaderMetadata = ex.ResponseHeaderMetadata;
     }
 }
コード例 #2
0
        /**
         * Look for additional error strings in the response and return formatted exception
         */
        private MarketplaceWebServiceProductsException ReportAnyErrors(String responseBody, HttpStatusCode status, ResponseHeaderMetadata rhm, Exception e)
        {
            MarketplaceWebServiceProductsException 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 MarketplaceWebServiceProductsException(message, status, code, "Unknown", requestId, responseBody, rhm);
                }
                else if (errorMatcherTwo.Success)
                {
                    String code      = errorMatcherTwo.Groups[1].Value;
                    String message   = errorMatcherTwo.Groups[2].Value;
                    String requestId = errorMatcherTwo.Groups[4].Value;

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