CodeSOD: Exceptional Content Sources

Joe sends us some Visual Basic .NET exception handling. Let’s see if you can spot what’s wrong?

Catch ex1 As Exception

    ' return the cursor
    Me.Cursor = Cursors.Default

    ' tell a story
    MessageBox.Show(ex1.Message)
    Return

End Try

This code catches a generic exception, messes with the cursor a bit, and then pops up a message box to alert the user that something has gone wrong. I don’t like putting an unhandled exception in a message box, but this is hardly WTF, is it?

Catch ex2 As Exception

    ' snitch
    MessageBox.Show(ex2.ToString(), "RSS Feed Initialization Failure")

End Try

Elsewhere in the app. Okay, I don’t like it either exN nor the naming convention, but where’s the WTF?

Well, the fact that they initialize the RSS feed is a hint – this isn’t a client RSS reader, it’s a web application that serves RSS. This is done on the server side and any message boxes that appear do not go to the end user.

Now, I haven’t seen this exact thing done in VB .Net, only in classic ASP, where could absolutely open message boxes on the web server. I hope that something in ASP .Net will prevent you from doing that. I would hope so.

By the way, I have found the worst note taking system you can make.

[Advertisement]

Use BuildMaster to release your software with confidence, at the pace your business demands. Download today!

Source link

Leave a Reply

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