From a066490b28c70f3b3ba6e8cbf7b5bfa7157b3cc9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 7 Jul 2017 09:58:28 +0200 Subject: [PATCH] + exception handling in FreeCADGui.addModule --- src/Gui/ApplicationPy.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index fcaa2378d0..8457b99422 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -1111,10 +1111,17 @@ PyObject* Application::sAddModule(PyObject * /*self*/, PyObject *args,PyObject * char *pstr=0; if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C return NULL; // NULL triggers exception - Command::addModule(Command::Doc,pstr); - Py_INCREF(Py_None); - return Py_None; + try { + Command::addModule(Command::Doc,pstr); + + Py_INCREF(Py_None); + return Py_None; + } + catch (const Base::Exception& e) { + PyErr_SetString(PyExc_ImportError, e.what()); + return 0; + } } PyObject* Application::sShowDownloads(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)