Today I encountered an exception thrown from a class library I was using that had an interesting exception message. Actually, the only thing interesting about it was how completely useless it was. Without revealing the identity of the class library, I will paraphrase. I was calling a method called "Initialize" on an object of a class, which I will call MyClass for ambiguity. The exception message was...
"Failed to initialize MyClass"
Ok, let's examine this for a moment. "Initialize" is the name of the method and, thus, what the method is supposed to do, which is what this is saying it failed to do. Let me illustrate how meaningless this is by saying it with a slightly different wording:
"The method you just called failed to do what it is supposed to do to the object it was called on because of an error that we are going to tell you nothing about. In fact, the original exception would have given you some useful information to go off of, but we decided to catch this exception and throw you this useless one instead, without even referencing the original as the inner exception we might add, because we enjoy frustrating our customers. It's all part of our elaborate plan to make you contact us to help you solve the issue. This way we appear needed to our employer even though we are lazy and continue to write crappy code. We don't care that this wastes your time and contributes towards delaying the very time-critical project you are trying to finish while your boss rides you every day about where you are on it. All we care about is keeping our jobs since we haven't the slightest clue what we're doing here."
The person I talked to today was lucky that I'm generally a nice guy, otherwise her day might have turned real ugly. But, fortunately, it didn't waste too much time--if half the day doesn't count as too much time, that is. It turns out the problem was quite simple. The error could have easily been summarized in an exception message like "The given system name was not found on the given server." Now would that have been so hard for the programmer who wrote that method to type that instead of "Failed for some reason"?
So next time you find yourself starting a line of code with "throw new", please, for the sake of programmers everywhere, at least say something about what the problem is, and include the original exception, if any, as the inner exception.
P.S. Comments are still not working... Sorry.