Why Not To Catch General Exception Types(blogs.msdn.com)

submitted by senfosenfo(881) 4 years, 6 months ago

In its best practices guideline, Microsoft specifies that a generic Exception should not be caught. But why is this?

3 comments |category: |Views: 37

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by tortustortus(25) 4 years, 6 months ago 0

of of my "favorite" projects I worked on was when a developer would always do try { ScaryThing(); } catch { /* completely empty */ }, this was his exception handler for all situations.

I knew I hit one of his bugs when all of a sudden the app just stopped dead in its tracks, and boy were they fun to track down...

Reply

posted by senfosenfo(881) 4 years, 6 months ago 0

tortus, I've also run across "error handlers" written like that. And you're right, they can be incredibly frustrating. But that was nothing compared to what a friend of mine was working on. Code written by the same guy that wrote the frustrating code I ran into, a new project was throwing literally thousands of exceptions per minute to mask bugs. It was an incredibly idiotic design, to say the least. Surprisingly, the lead developer on the project saw absolutely nothing wrong with the project and how it handled exceptions. Truly a case where the people in charge were entirely too incompetent to perform their job, but had too much power to allow anything to change.

Reply

posted by fehaarfehaar(580) 4 years, 6 months ago 0

Empty catch clauses and using exceptions instead of normal error handling are mortal sins that require immidiate crucifiction when encountered. ;-)

Reply

information Login or create an account to comment on this story