Exception Handling in Python 3

John Nagle nagle at animats.com
Mon Nov 1 13:56:51 EDT 2010


On 10/24/2010 5:36 AM, Steve Holden wrote:
> On 10/24/2010 2:22 AM, Lawrence D'Oliveiro wrote:
>> In message<mailman.176.1287896531.2218.python-list at python.org>, Steve
>> Holden wrote:

> Yes, *if the exception is caught* then it doesn't make any difference.
> If the exception creates a traceback, however, I maintain that the
> additional information is confusing to the consumer (while helpful to
> the debugger of the consumed code).

     If an exception propagates all the way out to the top level and
all the user gets is a system traceback, the program isn't very
good.  Really.  If you're concerned about the display format of
Python tracebacks seen by end users, you have bigger problems
with your code.

     If it's a server-side program, you need to catch
exceptions and log them somewhere, traceback and all.  If it's
a client-side GUI program, letting an exception unwind all the
way out of the program loses whatever the user was doing.

     It's usually desirable to at least catch EnviromentError near
the top level of your program.  If some external problem causes a
program abort, the user should get an error message, not a traceback.
If it's a program bug, you can let the traceback unwind, displaying
information that should be sent in with a bug report.

				John Nagle



More information about the Python-list mailing list