March 10, 2008 01:17 by
Admin
Keyvan Nayyeri has a very cool example of using extension methods to add a Log method to all Exceptions. The result is very cool:
try
{
throw new ApplicationException("Shouldn't have gotten here...");
}
catch (ApplicationException e)
{
e.Log();
}
Now I can catch any exception and easily get the message logged into my logging framework! Admittedly, it isn't much different than calling a static method like my Log.Exception(e), but at first glance, it seems easier to remember...
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5