With apologies to A Few Good Men#

“You want to catch the base exception?  You want to catch the base exception?  You can't handle the base exception!”  Ok, Jack never said that.  But he should have.

This is a very important point that hasn't hit home with a lot of co-workers.  I wonder if it stems from the VB habit of handling every error in a single On Error Goto statement (or worse, On Error Resume Next).  I'll admit, I didn't initially buy into it, until I had a good understanding of what it meant.  By catching the base exception, you are explicitly stating that you know how to handle the exception -- even though you don't know why it happened!  If you knew it could happen and how to handle it, you would catch that specific exception type. 

Granted, you need to be able to log the error, so you know that it happened.  That's where top-level “unhandled exception“ events come into play: AppDomain.UnhandledException, Application.ThreadException, and HttpApplication.Error.

For all the details go read Jason Clark's article in this month's MSDN Magazine.  He does a great job of explaining how to properly handle exceptions.  That's what inspired me to write this post.

 

Thursday, May 20, 2004 5:49:00 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Comments are closed.
All content © 2012, josh
About this site
Send mail to the author(s) Contact me
Feed your aggregator (RSS 2.0)
Joshua Flanagan
I am a software developer focused on continuous improvement in the .NET community
Los Techies

On this page
Archives
Rest of the world

Acknowledgements

Powered by: newtelligence dasBlog 2.1.8209.14743

Special thanks to LosTechies.com

Site theme based on the essence design by Jelle Druyts

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.