Well, ever since Joel took notice of my article about exceptions and status returns, the weblog joint has really been jumping. Joel asks me to give real examples rather than “DoSomething” for function names. It’s kind of a funny request, since his example used functions named “f” and “g”, but it makes sense to ground this in reality.
In response, I wrote another article laying out my view of how exceptions fit into real code: Exceptions in the rainforest.
A number of people rose to Joel’s challenge before I could:
- Len Holgate has a good example of how to handle the “failure during installation” scenario.
- Jesse Ezell tries his hand at it, though I don’t think I like his first try: checking the class of the exception seems a particularly awkward defense of exceptions.
- Steve Tibbett shows some other ways to slice it (though I don’t approve of “catch (...)”).