Boost logo

Boost :

Subject: Re: [boost] [Python] Improved exception handling for Python embedding
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2014-08-01 15:27:37


On Fri, Aug 1, 2014 at 4:40 AM, Michael Koenig <
michael.koenig_at_[hidden]> wrote:

> Hey guys!
>
> Boost.Python throws boost::python::error_already_set exceptions whenever
> calls to embedding functions such as boost::python::import() or
> boost::python::exec() fail.
>
> This exception is just an empty class. It does not provide any information
> on the error which occurred on the Python side. It is not even a standard
> exception in the C++ sense.
>

I took a quick look -- if I read the code right, the Boost Python exception
types don't even derive from std::exception. I can't think of any reason
why that's done, you're right that it should be fixed.

Secondly, I suggest using BOOST_THROW_EXCEPTION to throw. This would allow
arbitrary information to be attached to the exception object, not only at
the throw site but also at a later time. See
http://www.boost.org/doc/libs/release/libs/exception/doc/tutorial_transporting_data.html
.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk