public static bool ShouldRetry()

in Darabonba/Core.cs [199:247]


        public static bool ShouldRetry(RetryOptions options, RetryPolicyContext ctx)
        {
            if (ctx.RetriesAttempted == 0)
            {
                return true;
            }
            if (options == null || options.Retryable == null || options.Retryable == false)
            {
                return false;
            }

            if (ctx.Exception is DaraException)
            {
                var daraException = (DaraException)ctx.Exception;
                List<RetryCondition> noRetryConditions = options.NoRetryCondition;
                List<RetryCondition> retryConditions = options.RetryCondition;

                if (noRetryConditions != null)
                {
                    foreach (var noRetryCondition in noRetryConditions)
                    {
                        if (DictUtils.Contains(noRetryCondition.Exception, daraException.Message) ||
                            DictUtils.Contains(noRetryCondition.ErrorCode, daraException.Code))
                        {
                            return false;
                        }
                    }
                }
                if (retryConditions != null)
                {
                    foreach (var retryCondition in retryConditions)
                    {
                        if (!DictUtils.Contains(retryCondition.Exception, daraException.Message) &&
                            !DictUtils.Contains(retryCondition.ErrorCode, daraException.Code))
                        {
                            continue;
                        }

                        if (ctx.RetriesAttempted > retryCondition.MaxAttempts)
                        {
                            return false;
                        }

                        return true;
                    }
                }
            }
            return false;
        }