diff --git a/src/dynamic-graph-py.cc b/src/dynamic-graph-py.cc index 01f69634e71d2fc048bde4c92ea8f54ecfbd6b9d..54a4eb144cbbef113bce929565dce1ba19e428bb 100644 --- a/src/dynamic-graph-py.cc +++ b/src/dynamic-graph-py.cc @@ -10,6 +10,8 @@ #include <dynamic-graph/interpreter.h> +static PyObject* error; + static dynamicgraph::Interpreter interpreter; static PyObject* @@ -24,7 +26,12 @@ plug(PyObject* self, PyObject* args) std::ostringstream os; ss << std::string(out) << " " << std::string(in); std::istringstream cmdArg(ss.str()); - interpreter.cmdPlug(std::string("plug"), cmdArg, os); + try { + interpreter.cmdPlug(std::string("plug"), cmdArg, os); + } catch (dynamicgraph::ExceptionFactory& exc) { + PyErr_SetString(error, exc.getStringMessage().c_str()); + return NULL; + } return Py_BuildValue(""); } @@ -46,4 +53,8 @@ initwrap(void) m = Py_InitModule("wrap", sotTutorialMethods); if (m == NULL) return; + + error = PyErr_NewException("dynamic_graph.wrap.error", NULL, NULL); + Py_INCREF(error); + PyModule_AddObject(m, "error", error); }