The Artima Developer Community
Sponsored Link

.NET Buzz Forum
What's wrong with this code redux...

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Gunnerson

Posts: 1006
Nickname: ericgu
Registered: Aug, 2003

Eric Gunnerson is a program manager on the Visual C# team
What's wrong with this code redux... Posted: Mar 18, 2004 1:38 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Eric Gunnerson.
Original Post: What's wrong with this code redux...
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Eric Gunnerson
Latest Posts From Eric Gunnerson's C# Compendium

Advertisement

Thanks to all for their comments on “what's wrong with this code”.

I will confess to making a tactical error in presenting the code. I started only showing a single error, and then I went back and showed another one.

Ones that people commented on:

Not checking for InnerException to be null

I didn't intend this one, so +1 for my readers

Datastore not getting tested in the use

I hadn't intend this to be a full, usable class, so there's other code not shown that makes this a non-error.

Error in constructor

This was the error that I added, which just confused this issue. Whidbey may catch this one - I'm not sure.

Not rethrowing in the catch

This was the error I was intending to highlight. The code I wrote swallows all errors that weren't of the proper type.

There are really two issues with this code. The first is the more obvious one - the fact that I'm dealing with one type of exception, and not rethrowing all the other types.

The more subtle issue is that the api that I'm calling is flawed. APIs should never force their users to have to depend on the inner exception for everything. If you find your users writing code like that, you haven't given them enough richness in the set of exceptions that you throw.

 

Read: What's wrong with this code redux...

Topic: zero or one based collection? Previous Topic   Next Topic Topic: What's wrong with this code?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use