Thursday, June 02, 2005

Don't Ignore Exceptions!

I found a great post on Gregg M's blog talking about the importance of reporting exceptions instead of ignoring them. A couple years ago I started some code reviews of a software package littered with sections like this: try {    //Do semi-important stuff here } catch (Exception e) { } Gee, do you think any Exceptions generated in the try block might have actually been, oh, maybe important? The same code ignored return values from many API calls, including database transactions. It's not like we're worried whether or not a transaction was successful or not, are we? But that's a rant for another time. Check out Gregg's post for some good reasons why Exceptions should not be handled as per the example above, plus a few suggestions on how to go about notifying the system about unexpected Exceptions. (On a side note, I really appreciate the experience and smarts of the MSDN bloggers, but would it be too much to ask that they put an "About" section on their blogs? Am I supposed to slog through a year's worth of posts to try and figure out who Gregg M or Cyrus are? They've got great content; I'd just love to know where they fit in the picture. Rant off.)

No comments:

Subscribe (RSS)

The Leadership Journey