Exceptional Conditions: when to ignore, assert, raise, log, except, or email?
When programming in Python, we often run into situations which are not "normal" or expected.
Python allows you to deal with these situations in any number of different ways:
- ignoring the error (letting some lower-level library raise an exception)
- asserting an assumption (raising a generic error that says something shouldn't have happened)
- raising an explicit error
- returning a "success" flag with your "real" return value
- providing finally/context-manager operations (unconditional cleanup)
- logging the exceptional condition and continuing
- logging the condition into a database
- sending a syslog message
- catching a particular error
- catching all errors
- displaying a nice error message to the user
- emailing a user
In our round-table we'll try to hash out when/where/why you would choose any or all of these approaches. Do you have coding standards that make exceptional conditions un-exceptional? Do you have tools you use to make logs more useful? Do you have a rule-of-thumb you apply to choose an approach? Are there different requirements for GUI versus Web applications? What about embedded/appliance applications? How much information should a user be given about a failure condition? We'll look at the various tools available and how to use them as well.



