Pragmatic Exceptions

Dr. Dobb's Journal December, 2005


Tip #4: Make Only the Actionable Obvious

A general rule for showing obvious exception messages (such as in a dialog) should be: Show the message only if there is an immediate, reasonable course of action users can take. If none can be imagined, then either the exception can be quietly logged in the background or it's serious enough to crash the application now, before doing any further damage.

An example of an actionable message would be: "The file you were editing was updated; load the new version?"

File changes to the currently edited file are exceptional conditions that, internally, could very well generate exceptions. In such a case, showing users what happened and offering some course of action is the best approach.

But what about showing a dialog (or console message) just before the application crashes that points to the the log file? Go for it. This still fits the rule since they can take action by examining the log.

—Benjamin Booth
benjamin.booth@gmail.com