Added DTRException translator to python world

This commit is contained in:
Damien Dupuis 2010-04-06 11:45:03 +00:00
parent 306c391a11
commit 4d1e23eaea
1 changed files with 9 additions and 0 deletions

View File

@ -3,8 +3,13 @@ using namespace boost::python;
#include "io/dtr/Techno.h"
#include "io/dtr/Rules.h"
#include "io/dtr/DTRException.h"
namespace DTR {
void translator(DTRException const& e) {
PyErr_SetString(PyExc_UserWarning, e.what());
}
BOOST_PYTHON_MODULE(pyDTR) {
// class DTR::Name
class_<Name>("Name", init<std::string>())
@ -39,5 +44,9 @@ BOOST_PYTHON_MODULE(pyDTR) {
.def("getValue" , static_cast<double(Techno::*)(Name, Name )>(&Techno::getValue))
.def("getValue" , static_cast<double(Techno::*)(Name, Name, Name)>(&Techno::getValue))
;
// DTRException translator
register_exception_translator<DTRException>(translator)
;
}
}