Enumerating Exceptions using ForEach

Wednesday, September 05, 2007 4:51:50 AM (GMT Daylight Time, UTC+01:00)

Thought I would share this class I wrote the other day... it is a helper class that flattens the the Exception hierarchy and allows you to enumerate through the exceptions using ForEach. The following shows how the class is used.

 

EnumerableException items = new EnumerableException(ex);

 

foreach (EnumerableException item in items)

    System.Diagnostics.Debug.WriteLine(item.Exception.Message);

 

The following is the source: EnumerableException.zip