public static List <T> SafeToList <T>(this IEnumerable <T> @this) { try { return(@this.ToList()); } catch (Exception e) { var msg = $"{nameof(SafeToList)}<{typeof(T).Name}>"; _logger.Warn(e, msg); DebuggerExt.BreakIfAttached(); } return(new List <T>()); }
public static IEnumerable <T> SafeWhere <T>(this IEnumerable <T> @this, Func <T, bool> predicate) { Contract.Assert(predicate != null); return(@this.Where(item => { try { return predicate(item); } catch (Exception e) { var msg = $"{nameof(SafeWhere)}<{typeof(T).Name}>"; _logger.Warn(e, msg); DebuggerExt.BreakIfAttached(); } return false; })); }