Build-in or user-defined exceptions?
Torsten Bronger
bronger at physik.rwth-aachen.de
Sat May 14 09:13:14 EDT 2005
Hallöchen!
I write a module, and so I must raise exceptions at several points.
The PEP 8 says that a module should define their own exceptions base
class, derived from "Exception", and derivatives of that.
However, the build-in exceptions cover most of the error types that
occur in a standard program. For example, my module communicates
with measurement instruments, so any communication error would fit
perfectly to the build-in "IOError", wouldn't it? Invalid arguments
can raise "TypeError"s, and so on and so forth.
Is it considered good style to raise build-in exceptions whereever
one thinks it's appropriate? Is the definition of module exceptions
derived from "IOError", "TypeError" etc. a good idea? Is there some
sort of style guide for recommended exceptions design in Python?
Thank you!
Tschö,
Torsten.
--
Torsten Bronger, aquisgrana, europa vetus
More information about the Python-list
mailing list