I just stumbled across the following SQL 2005 code:
BEGIN TRY UPDATE [tabProgramSite] SET [Name] = @ProgramSiteName WHERE [ProgramSiteID] = @ProgramSiteId END TRY BEGIN CATCH END CATCH
Nothing like catching an error… and doing nothing about it. I hope the user experience isn’t as robust.
Lucas says:
Sounds familiar! I recently went through the source code of a production application adding (at least) some logging code into hundreds (well, maybe just dozens) of empty catches.
It was VERY frustrating when the client reported a problem and sent us log files, and the logs didn’t have the slightest hint of what the problem was. Here we say the application “eats” the exceptions. om nom nom nom …
The fact that it was written in VB was also frustrating, but that’s just me 🙂
brian says:
VB… the language that should not be.
harborpirate says:
Even worse is that in many cases you take a performance hit (though slight) for adding an exception handling routine. This is a great trade-off when you get a more robust application out of it since the difference is extremely small. When you have an empty catch you’re screwing yourself twice. Errors won’t bubble out to the calling software so you won’t know what happened AND your code will run ever so slightly slower.
brian says:
Having a try/catch block without anything in the catch is like fishing and never looking at what’s on the hook.