Wednesday, 28 August 2013

What is the best practise for capturing all inner exception details?

What is the best practise for capturing all inner exception details?

What is the best practice for logging complete exception details including
all possible inner exceptions?
Currently, I use the following code:
try
{
//some code that throws an exception
}
catch(Exception ex)
{
do
{
Console.WriteLine(ex.Message+ex.StackTrace);
ex=ex.InnerException;
}while(ex!=null)
}
Are there any scenarios where this code may fail?

No comments:

Post a Comment