I found out that if I am catching an Exception e, e.innerException could possibly be null.
Is it also possible that e.StackTrace could also be null in any possible circumstance in a catch block?
try {
}
catch(Exception e)
{
//can e.StackTrace be null here?
}
Yes.
If you create a new Exception()
and don't throw it, every property except Data
and Message
will be null.
An example that proves the StackTrace
can be null in a catch block is equally trivial to show:
public class DerpException : Exception
{
public override string StackTrace
{
get { return null; }
}
}