Skip to content
Snippets Groups Projects
Commit 25894620 authored by florent's avatar florent
Browse files

Raise a python exception upon c++ exception in plug command

	* src/dynamic-graph-py.cc.
parent 669a83f7
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include <dynamic-graph/interpreter.h> #include <dynamic-graph/interpreter.h>
static PyObject* error;
static dynamicgraph::Interpreter interpreter; static dynamicgraph::Interpreter interpreter;
static PyObject* static PyObject*
...@@ -24,7 +26,12 @@ plug(PyObject* self, PyObject* args) ...@@ -24,7 +26,12 @@ plug(PyObject* self, PyObject* args)
std::ostringstream os; std::ostringstream os;
ss << std::string(out) << " " << std::string(in); ss << std::string(out) << " " << std::string(in);
std::istringstream cmdArg(ss.str()); 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(""); return Py_BuildValue("");
} }
...@@ -46,4 +53,8 @@ initwrap(void) ...@@ -46,4 +53,8 @@ initwrap(void)
m = Py_InitModule("wrap", sotTutorialMethods); m = Py_InitModule("wrap", sotTutorialMethods);
if (m == NULL) if (m == NULL)
return; return;
error = PyErr_NewException("dynamic_graph.wrap.error", NULL, NULL);
Py_INCREF(error);
PyModule_AddObject(m, "error", error);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment