[C++-sig] Re: Wrapper for exception translation

David Abrahams dave at boost-consulting.com
Fri Aug 1 18:39:25 CEST 2003

Gottfried Ganßauge <ganssauge at gmx.de> writes:

> Hi Dave,
> I digged through the class_<> implementation and I think I know what I must
> do to implement it. Like you suggested I would add another argument to the
> class_base constructor which is used as another base class for the newly
> created class.
> The only problem I'm having is the programming interface for the user:
> I could the simply pass a const pointer to the python exception type to the
> protected class_<> constructor. This would - at least for my feeling - look
> a bit strange because this would be the only low level python detail on this
> level. Additionally it would require from the programmer that he knows the
> low level name of  the exception type.
> Alternatively I could create an object wrapper around the exception types
> and pass a const reference to one of those. This is not too complicated but
> it takes it's time. Furthermore I'm not sure about your reaction to my plans
> being too complicated :-(.

Your plans are complex, but comprehensible and clean.  So I support

Ultimately, I'd like to have an object wrapper around all of the
exception classes.  I'd like to present as much of the Python API as
possible at a high level.  It would be great if we could also do:

    throw IndexError(some_argument);

And have it mean the same as:

    >>> raise IndexError, some_argument

> I'm on vacation this week and the next so I currently work only
> sporadically.
> I think I could have a first prototype by monday, august 18.

Sounds very promising; I look forward to it!

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list