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.