Tuesday, April 24, 2007

"Catch all the exceptions, ALL OF THEM!!!"

"Catch all the exceptions, ALL OF THEM!!!" were the words that ran thru my head as a saw the dreaded
..catch(Exception)
{}...

WTF??!?!

a)Why would you ever catch all exceptions? You should know what exceptions are coming back at you catch specific ones and deal with them appropriately. The only* time I could ever see this being usefull is for logging purposes...
b)Dont hide exceptions... deal with them. Catch exceptions and doing nothing is pretty rank... at least comment the hell out of why you are doing it.
c)Get FXcop or some tool that tells you when there is rubbish code in your solution!

*OK there is probably a few areas, but not as many as some would think...

No comments: