CodeSOD: Exceptional Feeds
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) ReturnEnd Try
This code catches the generic exception, meddles with the cursor a bit, and then pops up a message box to alert the user to something that went wrong. I don't love putting the raw exception in the message box, but this is hardly a WTF, is it?
Catch ex2 As Exception ' snitch MessageBox.Show(ex2.ToString(), "RSS Feed Initialization Failure")End Try
Elsewhere in the application. Okay, I also don't love the exN naming convention either, but where's the WTF?
Well, the fact that they're initializing an RSS feed is a hint- this isn't an RSS reader client, it's an RSS serving web app. This runs on the server side, and any message boxes that get popped up aren't going to the end user.
Now, I haven't seen this precise thing done in VB .Net, only in Classic ASP, where you could absolutely open message boxes on the web server. I'd hope that in ASP .Net, something would stop you from doing that. I'd hope.
Otherwise, I've found the worst logging system you could make.
[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!