Exception as the primary error handling mechanism?

Martin v. Loewis martin at v.loewis.de
Sat Jan 2 07:52:10 EST 2010


> I mentioned an "exception stack" above, though I'm not 100% sure if that is 
> the proper term. I think that exceptions can be stacked upon each other 
> (e.g. an HTTPD throwing a high-level RequestError when it encounters a low-
> level IOError) and that that is also how the backtrace is implemented, but 
> I'm not sure about that.

Not exactly. In this scenario, the IOError exception gets caught, its
entire traceback discarded, and an entirely new exception RequestError
gets raised (that has no connection to the original IOError anymore,
unless the httpd code explicitly links the two).

Instead, the traceback objects are created for a single exception.
They are essentially the same as the call stack, just in reverse
order (so that you get the "most recent call last" traceback output).
Each traceback links to a frame object, and a next traceback object.

Regards,
Martin



More information about the Python-list mailing list