CodeSOD: Caught Something

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:

This combines a whole bunch of WTFs:

  1. Error suppression in payment processing code
  2. Try/catch in place of checking error conditions
  3. Willful laziness, as documented the coder's comment
[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!

This post originally appeared on The Daily WTF.

Leave a Reply

Your email address will not be published. Required fields are marked *