Enumerating Exceptions using ForEach

Tuesday, September 04, 2007 9:51:50 PM (Central Standard Time, UTC-06: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