using System; using System.Collections.Generic; using System.Linq; namespace UnityEngine.Purchasing { static class EnumerableExtensions { public static IEnumerable NonNull(this IEnumerable enumerable) { return enumerable.Where(obj => obj != null); } public static IEnumerable IgnoreExceptions(this IEnumerable enumerable, Action onException = null) where TException : Exception { using var enumerator = enumerable.GetEnumerator(); var hasNext = true; while (hasNext) { try { hasNext = enumerator.MoveNext(); } catch (TException ex) { onException?.Invoke(ex); continue; } if (hasNext) { yield return enumerator.Current; } } } } }