|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-09-27 15:33:26
----- Original Message -----
From: " Kerim Borchaev ( WarKiD ) " <warkid_at_[hidden]>
> Is there a way to raise a python exception from an extension?
>
> Best regards,
> Kerim mailto:warkid_at_[hidden]
There are two ways:
1. Raise an exception derived from std::exception. It will be translated to
a Python exception (see handle_exception() in conversions.cpp).
2. Use the standard Python interface to set an exception, then throw
boost::python::error_already_set(). E.g.:
const char message[] = "value out of range for Python int";
PyErr_SetString(PyExc_ValueError, message);
throw boost::python::error_already_set();
HTH,
Dave
===================================================
David Abrahams, C++ library designer
resume: http://users.rcn.com/abrahams/resume.html
C++ Booster (http://www.boost.org)
email: david.abrahams_at_[hidden]
===================================================
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk