Generic error handling
Alex Martelli
aleax at aleax.it
Sun Jan 13 11:10:49 EST 2002
Grzegorz Dostatni wrote:
> Hello...
> I am faced with working with a project in python where some of the code is
> loaded from a database. When I get an exception from such code the
> initial line shows ??? as the original source. Is it possible to a)
> include some info for traceback to show
Yes, for example if you 'load' your code with builtin function compile.
it takes a 'name' parameter just for this purpose. If you build the
runnable code up with functions from module new, similarly.
> b) catch the errors in a general
> way (no matter where they're execuded from) at an application level?
I think you're looking for sys.excepthook (it won't be there if your
version of Python is too old -- in this case, upgrade!).
Alex
More information about the Python-list
mailing list