CodeSOD: Caught Something
by Remy Porter from The Daily WTF on (#5XPP8)
One of the easiest ways to create a bug for yourself is to drop an empty catch into your application.
Today's rather short CodeSOD comes from Dex, and was found in a payment process. This is code that handles actual financial transactions, which is why the comment attached to a common mistake is relevant here:
catch // complete fubar but don't crash{}
And yes, when this exception happened, things were "fubar"- broken beyond all recognition, and unable to be recovered from. That's what drew Dex's attention to the code in the first place- trying to understand the mangled transactions which were passing through the system.
As Dex summarizes:
[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!This combines a whole bunch of WTFs:
- Error suppression in payment processing code
- Try/catch in place of checking error conditions
- Willful laziness, as documented the coder's comment