1 // Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>
2 // Copyright (C) 2005 The Trustees of Indiana University.
4 // Use, modification and distribution is subject to the Boost Software
5 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // Authors: Douglas Gregor
10 /** @file exception.cpp
12 * This file reflects the Boost.MPI @c mpi_error class into
15 #include <boost/python.hpp>
16 #include <boost/mpi/exception.hpp>
18 #include <boost/lexical_cast.hpp>
19 #include "utility.hpp"
21 using namespace boost::python
;
22 using namespace boost::mpi
;
24 namespace boost
{ namespace mpi
{ namespace python
{
26 extern const char* exception_docstring
;
27 extern const char* exception_what_docstring
;
28 extern const char* exception_routine_docstring
;
29 extern const char* exception_result_code_docstring
;
31 str
exception_str(const exception
& e
)
33 return str(std::string(e
.what()) +
34 " (code " + lexical_cast
<std::string
>(e
.result_code())+")");
37 void export_exception()
39 using boost::python::arg
;
40 using boost::python::object
;
44 ("Exception", exception_docstring
, no_init
)
45 .add_property("what", &exception::what
, exception_what_docstring
)
46 .add_property("routine", &exception::what
, exception_routine_docstring
)
47 .add_property("result_code", &exception::result_code
,
48 exception_result_code_docstring
)
49 .def("__str__", &exception_str
)
51 translate_exception
<exception
>::declare(type
);
54 } } } // end namespace boost::mpi::python