Code Snippet With Syntaxhighlighter Support for Windows Live Writer - Peter's Software House

Code Snippet With Syntaxhighlighter Support for Windows Live Writer

I found the PreCode AddIn for Windows Live Writer from Scott’s Blog.

So to celebrate ;) here is another WTF:

  try
  {
    // Some Code
  }
  catch (WebException we)
  {
      throw (we);
  }
  catch (Exception e)
  {
      throw (e);
  }
  finally
  {
  }

What is the point of catching these Exceptions?  Nothing!  You also loose all the StackTrace when an error does exist.   O yea and the finally block is totally superficial.

There are rules when dealing with Exceptions:

  1. Only catch exceptions if you can deal with them (Log it, gracefully exit, etc…).
  2. If you want to add additional value to the exception, create your own with the new information and use the caught exception as an inner exception.
  3. If for what ever reason you need to re-throw, then use “throw;” not “throw e;”.

I’m sure there is more, but for me these are probably the most important.

Published Thursday, June 18, 2009 11:18 AM by Pieter
Filed under: ,

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: