I am trying to log exceptions. It seems like I have to write the code for
each member that I would like to log.
It would be nice to replace this with code to enumerate an exception, but it
seems that exceptions do not have .getEnumerator().
Any ideas?
I would like to replace this:
public void LogNullReferenceException(NullReferenceException
NullReferenceException1)
{
Console.WriteLine(NullReferenceException1.Data);
Console.WriteLine(NullReferenceException1.HelpLink );
Console.WriteLine(NullReferenceException1.InnerExc eption);
Console.WriteLine(NullReferenceException1.Message) ;
Console.WriteLine(NullReferenceException1.Source);
Console.WriteLine(NullReferenceException1.StackTra ce);
Console.WriteLine(NullReferenceException1.TargetSi te);
}
with something like this psuedocode:
public void LogNullReferenceException(NullReferenceException
NullReferenceException1)
{
foreach (MemberInfo myMemberInfo in NullRefereneException1){
Console.WriteLine(myMemberInfo.Name + ":" + myMemberInfo.Value);
}
}