Files
modorganizer-plugin_python/src/runner/error.cpp
T
Tannin 6d99b33c61 - separated python proxy into two dlls. One is a wrapper without external
dependencies that fulfills the plugin interface. The other contains the actual python
functionality. This way the outer dll can always be loaded and report issues.
- The build process embeds the second dll into the first, this way only one dll has to be shipped
2013-09-01 18:36:43 +02:00

25 lines
726 B
C++

#include <boost/python.hpp>
#include <QString>
#include <utility.h>
using namespace MOBase;
namespace bpy = boost::python;
void reportPythonError()
{
if (PyErr_Occurred()) {
// prints to s_ErrIO buffer
PyErr_Print();
// extract data from python buffer
bpy::object mainModule = bpy::import("__main__");
bpy::object mainNamespace = mainModule.attr("__dict__");
bpy::object errMsgObj = bpy::eval("s_ErrIO.getvalue()", mainNamespace);
QString errMsg = bpy::extract<QString>(errMsgObj.ptr());
bpy::eval("s_ErrIO.truncate(0)", mainNamespace);
throw MyException(errMsg);
} else {
throw MyException("An unexpected C++ exception was thrown in python code");
}
}