// private methods
        private void AddErrorLabelIfRequired(Exception exception, int?maxWireVersion)
        {
            if (exception is MongoException mongoException)
            {
                if (ShouldAddTransientTransactionError(mongoException))
                {
                    mongoException.AddErrorLabel("TransientTransactionError");
                }

                if (RetryabilityHelper.IsCommandRetryable(_command) && maxWireVersion.HasValue)
                {
                    RetryabilityHelper.AddRetryableWriteErrorLabelIfRequired(mongoException, maxWireVersion.Value);
                }
            }
        }
        // private methods
        private void AddErrorLabelIfRequired(Exception exception, SemanticVersion serverVersion)
        {
            if (exception is MongoException mongoException)
            {
                if (ShouldAddTransientTransactionError(mongoException))
                {
                    mongoException.AddErrorLabel("TransientTransactionError");
                }

                if (RetryabilityHelper.IsCommandRetryable(_command))
                {
                    RetryabilityHelper.AddRetryableWriteErrorLabelIfRequired(mongoException, serverVersion);
                }
            }
        }
        // private methods
        private void AddErrorLabelIfRequired(Exception exception, SemanticVersion serverVersion)
        {
            if (exception is MongoException mongoException)
            {
                if (ShouldAddTransientTransactionError(mongoException))
                {
                    mongoException.AddErrorLabel("TransientTransactionError");
                }

                if ((exception is MongoConnectionException) || // network error
                    (Feature.RetryableWrites.IsSupported(serverVersion) &&
                     !Feature.ServerReturnsRetryableWriteErrorLabel.IsSupported(serverVersion)))
                {
                    RetryabilityHelper.AddRetryableWriteErrorLabelIfRequired(mongoException);
                }
            }
        }
Ejemplo n.º 4
0
 private bool ShouldRetryEndTransactionException(Exception exception)
 {
     return(RetryabilityHelper.IsRetryableWriteException(exception));
 }