Superclass for Errors?

Christian Joergensen mail at razor.dk
Wed Dec 27 15:31:31 EST 2006


"tac-tics" <tactics40 at gmail.com> writes:

> I have a program which has a GUI front-end which that runs a separate
> thread to handle all the important stuff. However, if there is a
> problem with the important stuff, I want the GUI to raise a MessageBox
> alert to indicate this.
>
> For exceptions, I can simply use a catch-all except statement like:
>
> try:
>     ...
> except Exception, error:
>     JOptionPane.showMessageDialog(self, "Error: %s" % error)
>
> Only, I want it to catch Errors as well. Right now, I'm using:
>
> try:
>     ...
> except (Exception, TypeError, NameError, RuntimeError, AttributeError),
> error:
>     JOptionPane.showMessageDialog(self, "Error: %s" % error)
>
> I was wondering if there is a superclass for TypeError, NameError,
> RuntimeError, AttributeError, etc.

See http://rgruet.free.fr/PQR25/PQR2.5.html#BuiltInExc

I would guess you're looking for StandardError.

-- 
Christian Joergensen | Linux, programming or web consultancy
http://www.razor.dk  |     Visit us at: http://www.gmta.info



More information about the Python-list mailing list