2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 04:42:28 +00:00
Files
python/test/exception_translator.cpp
Dave Abrahams fe3cf386c3 Python->C++ exception translation
[SVN r14800]
2002-08-13 00:45:09 +00:00

26 lines
462 B
C++

#include <boost/python/module.hpp>
#include <boost/python/exception_translator.hpp>
struct error {};
void translate(error const& e)
{
PyErr_SetString(PyExc_RuntimeError, "!!!error!!!");
}
void throw_error()
{
throw error();
}
BOOST_PYTHON_MODULE_INIT(exception_translator_ext)
{
using namespace boost::python;
register_exception_translator<error>(&translate);
module("exception_translator_ext")
.def("throw_error", throw_error);
}