Exemplo n.º 1
0
        public void OfficialTransientErrors_ShouldBeHandled()
        {
            var transientErrors = Helper.GenerateExceptions(OfficialTransientErrors.Errors);

            foreach (var transientError in transientErrors)
            {
                Assert.That(_strategy.IsTransient(transientError),
                            "SqlException with ErrorNumber {0} should be handled as transient.",
                            transientError.ErrorCode);
            }
        }
Exemplo n.º 2
0
        public bool IsTransient(Exception ex)
        {
            Tracer.TraceEvent(TraceEventType.Verbose, 0, "AzureSqlStrategy is starting");

            var msStrategy = new SqlDatabaseTransientErrorDetectionStrategy();

            var isTransient = msStrategy.IsTransient(ex);

            if (!isTransient)
            {
                SqlException sqlException;
                if ((sqlException = ex as SqlException) != null)
                {
                    var msg = sqlException.ToString().ToLower();

                    if (msg.Contains("physical connection is not usable"))
                    {
                        Tracer.TraceEvent(TraceEventType.Verbose, 0, "AzureSqlStrategy: physical connection is not usable");

                        isTransient = true;
                    }
                    else if (msg.Contains("timeout expired"))
                    {
                        Tracer.TraceEvent(TraceEventType.Verbose, 0, "AzureSqlStrategy: timeout expired");

                        isTransient = true;
                    }
                }
            }

            Tracer.TraceEvent(TraceEventType.Verbose, 0, "AzureSqlStrategy: is transient: {0}", isTransient);

            return(isTransient);
        }
Exemplo n.º 3
0
        private bool IsTransientAzureException(Exception ex)
        {
            if (ex == null)
            {
                return(false);
            }

            return(_entLibStrategy.IsTransient(ex) ||
                   IsNewTransientError(ex) ||
                   IsTransientAzureException(ex.InnerException));
        }
        private bool IsTransientException(Exception ex)
        {
            if (ex == null)
            {
                return(false);
            }

            // Unwrap exception to handle exceptions wrapped by NHibernate GenericAdoException
            var inner = ex.InnerException;

            return(inner_strategy.IsTransient(ex) || IsCustomTransientException(ex) || IsTransientException(inner));
        }
 /// <summary>
 /// Checks with enterprise library's default handler to see if the error is transient, additionally checks
 /// for such errors using the code in the in <see cref="IsTransientException"/> function.
 /// </summary>
 /// <param name="ex">Exception being checked.</param>
 /// <returns><c>true</c> if exception is considered transient, <c>false</c> otherwise.</returns>
 public bool IsTransient(Exception ex)
 {
     return(_sqltransientErrorDetectionStrategy.IsTransient(ex) || IsTransientException(ex));
 }
 private bool IsTransientInner(Exception exception)
 {
     return(this.CustomStrategyIsTransient(exception) || SqlDatabaseStrategy.IsTransient(exception) || StorageStrategy.IsTransient(exception));
 }