Module handling its own hierarchy of exceptions

Vincent Bernat vincent.bernat at raysa.org
Sun May 11 13:10:12 EDT 2003


Hello !

I am writing a Python module in C and I would like to allow it to
raise some exceptions. I know how to raise builtin exceptions and
simple custom exceptions. I would like to use a hierarchy of
exception, something like this :

Exception
|
\-MyModuleException
     |
     +- Except1
     +- Except2
     +- Except3
     +- Except4
         |
         +- Subexcept 1
         +- Subexcept 2

What would be the easy way to include this hierarchy of exceptions and
use it in my module (I am not familiar with embedding Python, but I
suppose I could embed a Python module containing this hierarchy
instead of writing all this in C) ?

Could someone point me a snippet of code to do this ? Or just an
existent module which has a clean "exception" interface, from which I
could build mine.
-- 
BOFH excuse #280: Traceroute says that there is a routing problem in
the backbone.  It's not our problem.




More information about the Python-list mailing list