ManagerTest.Database.ExecuteSql.HandleWithRetry C# (CSharp) Method

HandleWithRetry() private method

private HandleWithRetry ( string sql, Action action, int attempt ) : void
sql string
action Action
attempt int
return void
		private void HandleWithRetry(string sql, Action<string> action, int attempt)
		{
			try
			{
				action.Invoke(sql);
			}
			catch (Exception exception)
			{
				if (attempt < 6 && _errorChecker.IsTransient(exception))
				{
					Thread.Sleep(5);
					HandleWithRetry(sql, action, ++attempt);
				}

				var message = exception.Message;
				SqlException sqlException;
				if ((sqlException = exception as SqlException) != null)
				{
					message = message + Environment.NewLine + "Error numbers: " +
					          string.Join(", ", sqlException.Errors.OfType<SqlError>().Select(e => e.Number));
				}

				throw;
			}
		}
	}