Tuesday, December 8, 2015

Handling Inner Exception Messages in C#

If you have ever needed to log Inner Exception Messages, you may have encountered instances when you cannot directly use the .InnerException.Message property because the value may be null.  In addition, if you have a series of exceptions that occurred then you will need to recursively log all of the exceptions that occurred in the entire call stack.

Well, fortunately, you can implement this functionality as an Extension Method! 

The code to implement this Extension Method can be found here: https://britebit.wordpress.com/2014/05/16/unwrap-inner-exception-messages/

It is also available on GitHub here: https://gist.github.com/harrybiscuit/e84a9728e66958f3fde7#file-unwrapinnerexceptionmessages-cs

No comments:

Post a Comment