The Silent Exception

time to read 2 min | 332 words

What is the most useless, annoying, brainless thing that an application can do? It is to shout: "Error occured". Tell me you haven't ever sat in front of the computer, staring at a completely helpless error, knowing that the program had the information that you need, but it just won't tell you.

I just revised an exception message four times, and on each time, I added more and more information to it.

Here are the iterations:

  • Property must be virtual on classes with lazy loading enabled - This one explain the problem, but doesn't really say what happened to caused it.
  • Property must be virtual on classes with lazy loading enabled [ActiveRecord(Lazy=true)] - This one gives a little more info, now even someone without intimate knowledge of the way ActiveRecord works can just search for it.
  • Property DemoProp must be virtual because the class is lazy loaded [ActiveRecord(Lazy=true)]  - Better, now I've information that says where the error happened. I still don't know in which class this happened, and if this is a common name, I'm still in a problem.
  • Property DemoProp must be virtual because the class DemoClass is loaded loaded [ActiveRecord(Lazy=true)] - Much better, now I know the name of the property and the name of the class, I can easily find it, and fix it.

Any horror stories about silent exceptions? Any way to improve the exception?

BTW, there is another side to the coin, the verbos exception, but that isn't nearly that much of a problem. You can reduce information, but you can create it. On the other hand, the misleading exception is the worst beast of them all.