Esempio n. 1
0
        /// <summary>
        /// Determines whether the exception thrown by the server is a transient
        /// error.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <returns>
        /// True, if the server exception is a transient error, false
        /// otherwise.
        /// </returns>
        public override bool IsTransientError(Exception exception)
        {
            HttpStatusCode httpCode = 0;

            if (exception is AdWordsBulkRequestException)
            {
                AdWordsBulkRequestException e = (AdWordsBulkRequestException)exception;
                if (e.error != null)
                {
                    httpCode = (HttpStatusCode)e.error.code;
                }
            }
            else if (exception is WebException)
            {
                WebException e = (WebException)exception;
                httpCode = (e.Response as HttpWebResponse).StatusCode;
            }
            else
            {
                return(false);
            }
            switch (httpCode)
            {
            case HttpStatusCode.InternalServerError:
            case HttpStatusCode.BadGateway:
            case HttpStatusCode.ServiceUnavailable:
            case HttpStatusCode.GatewayTimeout:
            case HttpStatusCode.NotFound:
                return(true);

            default:
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Determines whether the exception thrown by the server is a transient
        /// error.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <returns>
        /// True, if the server exception is a transient error, false
        /// otherwise.
        /// </returns>
        public override bool IsTransientError(Exception exception)
        {
            if (exception is AdWordsBulkRequestException)
            {
                AdWordsBulkRequestException ex = (AdWordsBulkRequestException)exception;
                switch ((HttpStatusCode)ex.error.code)
                {
                case HttpStatusCode.InternalServerError:
                case HttpStatusCode.BadGateway:
                case HttpStatusCode.ServiceUnavailable:
                case HttpStatusCode.GatewayTimeout:
                case HttpStatusCode.NotFound:
                    return(true);

                default:
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }