If at first you don’t succeed…

26 11 2010

Today I came across one of the most Daily WTF worthy pieces of code I’ve seen in a long time:

    void SomeFunction()
                /* Slightly more than 50 lines of code
                 * some of which contain additional
                 * try/catch blocks
            catch (Exception) { }
        catch (Exception ex)
            Debug.Assert(false, ex.Message);

The consensus among the people I showed this to was that the inner try was added in order to solve an assert (I think this opinion was only mostly tongue in cheek…). In fact, since very few people use the debug build, both catch blocks are equivalent.

Unfortunately due to the fact that we’ve recently changed source control systems and that dos2unix was used at some point in the past the culprit will probably remain anonymous.




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: