• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright David Abrahams 2004. Distributed under the Boost
2 // Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4 #include <boost/python/module.hpp>
5 #include <boost/python/def.hpp>
6 #include <boost/python/exception_translator.hpp>
7 
8 struct error {};
9 
translate(error const &)10 void translate(error const& /*e*/)
11 {
12     PyErr_SetString(PyExc_RuntimeError, "!!!error!!!");
13 }
14 
throw_error()15 void throw_error()
16 {
17     throw error();
18 
19 }
20 
BOOST_PYTHON_MODULE(exception_translator_ext)21 BOOST_PYTHON_MODULE(exception_translator_ext)
22 {
23   using namespace boost::python;
24   register_exception_translator<error>(&translate);
25 
26   def("throw_error", throw_error);
27 }
28 
29