Tag Archives: fail fast

What’s so hard about exceptions?

I keep wondering… Why is it actually so hard to handle exceptions correctly?

There are a few ground rules to follow and still people tend to overcatch or throw far too general exception types. As a recent empirical study suggests, this seems to be a general problem throughout software development. There is a brief, very well written guideline for .NET development, I keep waving at my team. I bet there is a similar guide for Java as well – any suggestions?

But I think the problem with exceptions is not just some guidelines that should be followed. Not every developer (and certainly not every customer) is comfortable with the ideal of error that may pop up from out of nowhere. Errors are silently suppressed for the better looks. But missing functionality cannot be hidden. If it doesn’t save, it doesn’t save and I certainly want to know that…

Logging is a way, but there is no path around exceptions in object-oriented programming. Taken that, there is also no way around a fail fast ideology. If something has gone wrong and I cannot do anything about it, it’s best to tell the world and not to brush it under the carpet. That’s also the best way to learn, by the way.

So, the first thing to establish proper exception handling seems to be the introduction of a culture of openly accepted mistakes. “Anything we find now, we won’t find later on.” should be the new motto.