public static void Handle(this Exception @this, Action <Exception> handler) { foreach (var exception in @this.AsEnumerable()) { handler(exception); } }
public void AsEnumerable() { var exp = new Exception("MsgA", new Exception("MsgB")); var group = exp.AsEnumerable(item => item.InnerException) .ToList(); Assert.Equal("MsgA,MsgB", group.JoinStr(",", item => item.Message)); }