[Tutor] Why should modules or packages should define their own domain-specific base exception class?

brian arb brianjamesarb at gmail.com
Tue Apr 15 04:09:55 CEST 2014


I don't quite understand why the google python style guide recommends that
packages and modules we write should avoid using the catch-all except.
Instead the guide encourages you to write domain specific exception classes.

class Error(Exception):
  """..."""

class ThisSpecificError(Error):
  """..."""

class ThatSpecificError(Error):
  """..."""


try:
  ...
except mylib.Error:
  ...

REF.
http://google-styleguide.googlecode.com/svn/trunk/pyguide.html?showone=Exceptions#Exceptions

Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140414/4aa1c957/attachment-0001.html>


More information about the Tutor mailing list