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 LogNullReferenc eException(Null ReferenceExcept ion
NullReferenceEx ception1)
{
Console.WriteLi ne(NullReferenc eException1.Dat a);
Console.WriteLi ne(NullReferenc eException1.Hel pLink);
Console.WriteLi ne(NullReferenc eException1.Inn erException);
Console.WriteLi ne(NullReferenc eException1.Mes sage);
Console.WriteLi ne(NullReferenc eException1.Sou rce);
Console.WriteLi ne(NullReferenc eException1.Sta ckTrace);
Console.WriteLi ne(NullReferenc eException1.Tar getSite);
}
with something like this psuedocode:
public void LogNullReferenc eException(Null ReferenceExcept ion
NullReferenceEx ception1)
{
foreach (MemberInfo myMemberInfo in NullRefereneExc eption1){
Console.WriteLi ne(myMemberInfo .Name + ":" + myMemberInfo.Va lue);
}
}
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 LogNullReferenc eException(Null ReferenceExcept ion
NullReferenceEx ception1)
{
Console.WriteLi ne(NullReferenc eException1.Dat a);
Console.WriteLi ne(NullReferenc eException1.Hel pLink);
Console.WriteLi ne(NullReferenc eException1.Inn erException);
Console.WriteLi ne(NullReferenc eException1.Mes sage);
Console.WriteLi ne(NullReferenc eException1.Sou rce);
Console.WriteLi ne(NullReferenc eException1.Sta ckTrace);
Console.WriteLi ne(NullReferenc eException1.Tar getSite);
}
with something like this psuedocode:
public void LogNullReferenc eException(Null ReferenceExcept ion
NullReferenceEx ception1)
{
foreach (MemberInfo myMemberInfo in NullRefereneExc eption1){
Console.WriteLi ne(myMemberInfo .Name + ":" + myMemberInfo.Va lue);
}
}
Comment