diff --git a/src/App/Application.cpp b/src/App/Application.cpp index b81f095016..1677b64ba7 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -166,7 +166,7 @@ AppExport std::map Application::mConfig; // Custom Python exception types BaseExport extern PyObject* Base::BaseExceptionFreeCADError; -BaseExport extern PyObject* Base::BaseExceptionFreeCADAbort; +BaseExport extern PyObject* Base::PyExc_FC_FreeCADAbort; BaseExport extern PyObject* Base::PyExc_FC_XMLBaseException; BaseExport extern PyObject* Base::PyExc_FC_XMLParseException; BaseExport extern PyObject* Base::PyExc_FC_XMLAttributeError; @@ -365,9 +365,9 @@ void Application::setupPythonException(PyObject* module) Py_INCREF(Base::BaseExceptionFreeCADError); PyModule_AddObject(module, "FreeCADError", Base::BaseExceptionFreeCADError); - Base::BaseExceptionFreeCADAbort = PyErr_NewException("Base.FreeCADAbort", PyExc_BaseException, nullptr); - Py_INCREF(Base::BaseExceptionFreeCADAbort); - PyModule_AddObject(module, "FreeCADAbort", Base::BaseExceptionFreeCADAbort); + Base::PyExc_FC_FreeCADAbort = PyErr_NewException("Base.FreeCADAbort", PyExc_BaseException, nullptr); + Py_INCREF(Base::PyExc_FC_FreeCADAbort); + PyModule_AddObject(module, "FreeCADAbort", Base::PyExc_FC_FreeCADAbort); Base::PyExc_FC_XMLBaseException = PyErr_NewException("Base.XMLBaseException", PyExc_Exception, nullptr); Py_INCREF(Base::PyExc_FC_XMLBaseException); diff --git a/src/App/ApplicationPy.cpp b/src/App/ApplicationPy.cpp index 36c4dad69a..3317c70802 100644 --- a/src/App/ApplicationPy.cpp +++ b/src/App/ApplicationPy.cpp @@ -180,7 +180,7 @@ PyMethodDef Application::Methods[] = { "This only works if there is an active sequencer (or ProgressIndicator in Python).\n" "There is an active sequencer during document restore and recomputation. User may\n" "abort the operation by pressing the ESC key. Once detected, this function will\n" - "trigger a BaseExceptionFreeCADAbort exception."}, + "trigger a Base.FreeCADAbort exception."}, {NULL, NULL, 0, NULL} /* Sentinel */ }; @@ -292,7 +292,7 @@ PyObject* Application::sSetActiveDocument(PyObject * /*self*/, PyObject *args) GetApplication().setActiveDocument(pstr); } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return nullptr; } diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index 390fd2a72e..455b86dfe1 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -234,7 +234,7 @@ PyObject* DocumentPy::addObject(PyObject *args, PyObject *kwd) if (!pcFtr) { std::stringstream str; str << "No document object found of type '" << sType << "'" << std::ends; - throw Py::Exception(Base::BaseExceptionFreeCADError,str.str()); + throw Py::TypeError(str.str()); } // Allows to hide the handling with Proxy in client python code if (obj) { @@ -300,7 +300,7 @@ PyObject* DocumentPy::removeObject(PyObject *args) else { std::stringstream str; str << "No document object found with name '" << sName << "'" << std::ends; - throw Py::Exception(Base::BaseExceptionFreeCADError,str.str()); + throw Py::ValueError(str.str()); } } @@ -399,7 +399,7 @@ PyObject* DocumentPy::moveObject(PyObject *args) } else { std::string str("Failed to move the object"); - throw Py::Exception(Base::BaseExceptionFreeCADError,str); + throw Py::ValueError(str); } } diff --git a/src/App/ExtensionContainerPyImp.cpp b/src/App/ExtensionContainerPyImp.cpp index 9a6a2b9fcd..77e8d174f7 100644 --- a/src/App/ExtensionContainerPyImp.cpp +++ b/src/App/ExtensionContainerPyImp.cpp @@ -183,7 +183,7 @@ PyObject* ExtensionContainerPy::hasExtension(PyObject *args) { if (extension.isBad() || !extension.isDerivedFrom(App::Extension::getExtensionClassTypeId())) { std::stringstream str; str << "No extension found of type '" << type << "'" << std::ends; - throw Py::Exception(Base::BaseExceptionFreeCADError,str.str()); + throw Py::TypeError(str.str()); } bool val = false; @@ -212,7 +212,7 @@ PyObject* ExtensionContainerPy::addExtension(PyObject *args) { if (extension.isBad() || !extension.isDerivedFrom(App::Extension::getExtensionClassTypeId())) { std::stringstream str; str << "No extension found of type '" << typeId << "'" << std::ends; - throw Py::Exception(Base::BaseExceptionFreeCADError,str.str()); + throw Py::TypeError(str.str()); } //register the extension @@ -222,7 +222,7 @@ PyObject* ExtensionContainerPy::addExtension(PyObject *args) { delete ext; std::stringstream str; str << "Extension is not a python addable version: '" << typeId << "'" << std::ends; - throw Py::Exception(Base::BaseExceptionFreeCADError,str.str()); + throw Py::TypeError(str.str()); } GetApplication().signalBeforeAddingDynamicExtension(*getExtensionContainerPtr(), typeId); diff --git a/src/App/GroupExtensionPyImp.cpp b/src/App/GroupExtensionPyImp.cpp index 0764cc55ed..0bd9d269e0 100644 --- a/src/App/GroupExtensionPyImp.cpp +++ b/src/App/GroupExtensionPyImp.cpp @@ -50,7 +50,7 @@ PyObject* GroupExtensionPy::newObject(PyObject *args) return object->getPyObject(); } else { - PyErr_Format(Base::BaseExceptionFreeCADError, "Cannot create object of type '%s'", sType); + PyErr_Format(PyExc_TypeError, "Cannot create object of type '%s'", sType); return nullptr; } } diff --git a/src/Base/AxisPyImp.cpp b/src/Base/AxisPyImp.cpp index 05cbcd2509..25a7eb268b 100644 --- a/src/Base/AxisPyImp.cpp +++ b/src/Base/AxisPyImp.cpp @@ -77,7 +77,7 @@ int AxisPy::PyInit(PyObject* args, PyObject* /*kwd*/) return 0; } - PyErr_SetString(Base::BaseExceptionFreeCADError, "empty parameter list, axis or base and direction expected"); + PyErr_SetString(PyExc_TypeError, "empty parameter list, axis or base and direction expected"); return -1; } diff --git a/src/Base/Exception.cpp b/src/Base/Exception.cpp index 4bc13ee0da..ad83699093 100644 --- a/src/Base/Exception.cpp +++ b/src/Base/Exception.cpp @@ -181,7 +181,7 @@ const char* AbortException::what() const throw() PyObject * AbortException::getPyExceptionType() const { - return BaseExceptionFreeCADAbort; + return PyExc_FC_FreeCADAbort; } // --------------------------------------------------------- diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 3edca84a6d..10196e5650 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -112,7 +112,7 @@ void PyException::raiseException() { PP_PyDict_Object = nullptr; std::string exceptionname; - if (_exceptionType == Base::BaseExceptionFreeCADAbort) + if (_exceptionType == Base::PyExc_FC_FreeCADAbort) edict.setItem("sclassname", Py::String(typeid(Base::AbortException).name())); if (_isReported) @@ -120,7 +120,7 @@ void PyException::raiseException() { Base::ExceptionFactory::Instance().raiseException(edict.ptr()); } - if (_exceptionType == Base::BaseExceptionFreeCADAbort) { + if (_exceptionType == Base::PyExc_FC_FreeCADAbort) { Base::AbortException e(_sErrMsg.c_str()); e.setReported(_isReported); throw e; diff --git a/src/Base/MatrixPyImp.cpp b/src/Base/MatrixPyImp.cpp index 676d4c0f7a..4601c04c10 100644 --- a/src/Base/MatrixPyImp.cpp +++ b/src/Base/MatrixPyImp.cpp @@ -120,7 +120,7 @@ int MatrixPy::PyInit(PyObject* args, PyObject* /*kwd*/) return 0; } - PyErr_SetString(Base::BaseExceptionFreeCADError, "matrix or up to 16 floats expected"); + PyErr_SetString(PyExc_TypeError, "matrix or up to 16 floats expected"); return -1; } @@ -610,7 +610,7 @@ PyObject* MatrixPy::multiply(PyObject * args) return new VectorPy(new Vector3d(vec)); } - PyErr_SetString(Base::BaseExceptionFreeCADError, "either vector or matrix expected"); + PyErr_SetString(PyExc_TypeError, "either vector or matrix expected"); return nullptr; } diff --git a/src/Base/PlacementPyImp.cpp b/src/Base/PlacementPyImp.cpp index 3ed96ad601..3aaf319445 100644 --- a/src/Base/PlacementPyImp.cpp +++ b/src/Base/PlacementPyImp.cpp @@ -114,7 +114,7 @@ int PlacementPy::PyInit(PyObject* args, PyObject* /*kwd*/) return 0; } - PyErr_SetString(Base::BaseExceptionFreeCADError, "empty parameter list, matrix or placement expected"); + PyErr_SetString(PyExc_TypeError, "empty parameter list, matrix or placement expected"); return -1; } diff --git a/src/Base/PyObjectBase.cpp b/src/Base/PyObjectBase.cpp index 024dadb753..c5020ef2a7 100644 --- a/src/Base/PyObjectBase.cpp +++ b/src/Base/PyObjectBase.cpp @@ -37,7 +37,7 @@ using namespace Base; PyObject* Base::BaseExceptionFreeCADError = nullptr; -PyObject* Base::BaseExceptionFreeCADAbort = nullptr; +PyObject* Base::PyExc_FC_FreeCADAbort = nullptr; PyObject* Base::PyExc_FC_XMLBaseException = nullptr; PyObject* Base::PyExc_FC_XMLParseException = nullptr; PyObject* Base::PyExc_FC_XMLAttributeError = nullptr; diff --git a/src/Base/PyObjectBase.h b/src/Base/PyObjectBase.h index 45bb3a1857..93ef4542d3 100644 --- a/src/Base/PyObjectBase.h +++ b/src/Base/PyObjectBase.h @@ -414,7 +414,7 @@ BaseExport extern PyObject* BaseExceptionFreeCADError; #define PY_FCERROR (Base::BaseExceptionFreeCADError ? \ BaseExceptionFreeCADError : PyExc_RuntimeError) -BaseExport extern PyObject* BaseExceptionFreeCADAbort; +BaseExport extern PyObject* PyExc_FC_FreeCADAbort; BaseExport extern PyObject* PyExc_FC_XMLBaseException; BaseExport extern PyObject* PyExc_FC_XMLParseException; BaseExport extern PyObject* PyExc_FC_XMLAttributeError; diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index 73c6d3b003..aa39bb3fc8 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -1353,7 +1353,7 @@ PyObject* Application::sAddCommand(PyObject * /*self*/, PyObject *args) } } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return nullptr; } catch (...) { diff --git a/src/Gui/DocumentPyImp.cpp b/src/Gui/DocumentPyImp.cpp index d8987c89f9..11024ad140 100644 --- a/src/Gui/DocumentPyImp.cpp +++ b/src/Gui/DocumentPyImp.cpp @@ -262,7 +262,7 @@ PyObject* DocumentPy::mdiViewsOfType(PyObject *args) Base::Type type = Base::Type::fromName(sType); if (type.isBad()) { - PyErr_Format(Base::BaseExceptionFreeCADError, "'%s' is not a valid type", sType); + PyErr_Format(PyExc_TypeError, "'%s' is not a valid type", sType); return nullptr; } diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index 8353076e3c..cb88fe9b10 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -2375,7 +2375,7 @@ PyObject *SelectionSingleton::sGetSelectionObject(PyObject * /*self*/, PyObject return nullptr; } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return nullptr; } } diff --git a/src/Gui/View3DViewerPy.cpp b/src/Gui/View3DViewerPy.cpp index 4799ed04df..50a77042ca 100644 --- a/src/Gui/View3DViewerPy.cpp +++ b/src/Gui/View3DViewerPy.cpp @@ -396,7 +396,8 @@ Py::Object View3DInventorViewerPy::setupEditingRoot(const Py::Tuple& args) return Py::None(); } catch (const Base::Exception& e) { - throw Py::Exception(Base::BaseExceptionFreeCADError,e.what()); + e.setPyException(); + throw Py::Exception(); } catch (const std::exception& e) { throw Py::RuntimeError(e.what()); @@ -417,7 +418,8 @@ Py::Object View3DInventorViewerPy::resetEditingRoot(const Py::Tuple& args) return Py::None(); } catch (const Base::Exception& e) { - throw Py::Exception(Base::BaseExceptionFreeCADError,e.what()); + e.setPyException(); + throw Py::Exception(); } catch (const std::exception& e) { throw Py::RuntimeError(e.what()); diff --git a/src/Gui/ViewProviderLinkPyImp.cpp b/src/Gui/ViewProviderLinkPyImp.cpp index 1d1d0e7577..689266aa26 100644 --- a/src/Gui/ViewProviderLinkPyImp.cpp +++ b/src/Gui/ViewProviderLinkPyImp.cpp @@ -64,7 +64,8 @@ void ViewProviderLinkPy::setUseCenterballDragger(Py::Boolean arg) { try { getViewProviderLinkPtr()->enableCenterballDragger(arg); }catch(const Base::Exception &e){ - throw Py::Exception(Base::BaseExceptionFreeCADError,e.what()); + e.setPyException(); + throw Py::Exception(); } } diff --git a/src/Gui/ViewProviderPyImp.cpp b/src/Gui/ViewProviderPyImp.cpp index b1977eb3d4..e76360f118 100644 --- a/src/Gui/ViewProviderPyImp.cpp +++ b/src/Gui/ViewProviderPyImp.cpp @@ -85,7 +85,7 @@ PyObject* ViewProviderPy::addProperty(PyObject *args) if (!prop) { std::stringstream str; str << "No property found of type '" << sType << "'" << std::ends; - throw Py::Exception(Base::BaseExceptionFreeCADError,str.str()); + throw Py::TypeError(str.str()); } return Py::new_reference_to(this); @@ -352,7 +352,7 @@ PyObject* ViewProviderPy::setTransformation(PyObject *args) Py_Return; } - PyErr_SetString(Base::BaseExceptionFreeCADError, "Either set matrix or placement to set transformation"); + PyErr_SetString(PyExc_TypeError, "Either set matrix or placement to set transformation"); return 0; } diff --git a/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp b/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp index 2450f5754a..1bc6b39d2f 100644 --- a/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp +++ b/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp @@ -98,7 +98,7 @@ private: Gui::getMainWindow()->addWindow(view); } else { - throw Py::Exception(Base::BaseExceptionFreeCADError, "unknown filetype"); + throw Py::Exception(PyExc_IOError, "unknown filetype"); } return Py::None(); @@ -125,7 +125,7 @@ private: view->resize( 400, 300 ); Gui::getMainWindow()->addWindow(view); } else { - throw Py::Exception(Base::BaseExceptionFreeCADError, "unknown filetype"); + throw Py::Exception(PyExc_IOError, "unknown filetype"); } return Py::None(); @@ -173,10 +173,9 @@ private: for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { if ((*it)->getTypeId().isDerivedFrom(Drawing::FeatureViewPart::getClassTypeId())) { Drawing::FeatureViewPart* view = static_cast(*it); - std::string viewName = view->Label.getValue(); App::DocumentObject* link = view->Source.getValue(); if (!link) { - throw Py::Exception(Base::BaseExceptionFreeCADError, "No object linked"); + throw Py::ValueError("No object linked"); } if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { throw Py::TypeError("Linked object is not a Part object"); diff --git a/src/Mod/Fem/App/FemMeshPyImp.cpp b/src/Mod/Fem/App/FemMeshPyImp.cpp index 129aff807b..985a94edbd 100644 --- a/src/Mod/Fem/App/FemMeshPyImp.cpp +++ b/src/Mod/Fem/App/FemMeshPyImp.cpp @@ -96,7 +96,7 @@ int FemMeshPy::PyInit(PyObject* args, PyObject* /*kwd*/) } } catch (const Base::Exception &e) { - PyErr_SetString(Base::BaseExceptionFreeCADError,e.what()); + e.setPyException(); return -1; } catch (const std::exception &e) { @@ -652,15 +652,9 @@ PyObject* FemMeshPy::setTransform(PyObject *args) if (!PyArg_ParseTuple(args, "O!", &(Base::PlacementPy::Type), &ptr)) return 0; - try { - Base::Placement* placement = static_cast(ptr)->getPlacementPtr(); - Base::Matrix4D mat = placement->toMatrix(); - getFemMeshPtr()->transformGeometry(mat); - } - catch (const std::exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); - return 0; - } + Base::Placement* placement = static_cast(ptr)->getPlacementPtr(); + Base::Matrix4D mat = placement->toMatrix(); + getFemMeshPtr()->transformGeometry(mat); Py_Return; } @@ -674,7 +668,7 @@ PyObject* FemMeshPy::getFacesByFace(PyObject *args) try { const TopoDS_Shape& sh = static_cast(pW)->getTopoShapePtr()->getShape(); if (sh.IsNull()) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "Face is empty"); + PyErr_SetString(PyExc_ValueError, "Face is empty"); return 0; } @@ -689,7 +683,7 @@ PyObject* FemMeshPy::getFacesByFace(PyObject *args) return Py::new_reference_to(ret); } catch (Standard_Failure& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString()); + PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString()); return 0; } } @@ -704,7 +698,7 @@ PyObject* FemMeshPy::getEdgesByEdge(PyObject *args) try { const TopoDS_Shape& sh = static_cast(pW)->getTopoShapePtr()->getShape(); if (sh.IsNull()) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "Edge is empty"); + PyErr_SetString(PyExc_ValueError, "Edge is empty"); return 0; } @@ -719,7 +713,7 @@ PyObject* FemMeshPy::getEdgesByEdge(PyObject *args) return Py::new_reference_to(ret); } catch (Standard_Failure& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString()); + PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString()); return 0; } } @@ -733,7 +727,7 @@ PyObject* FemMeshPy::getVolumesByFace(PyObject *args) try { const TopoDS_Shape& sh = static_cast(pW)->getTopoShapePtr()->getShape(); if (sh.IsNull()) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "Face is empty"); + PyErr_SetString(PyExc_ValueError, "Face is empty"); return 0; } @@ -751,7 +745,7 @@ PyObject* FemMeshPy::getVolumesByFace(PyObject *args) return Py::new_reference_to(ret); } catch (Standard_Failure& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString()); + PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString()); return 0; } } @@ -765,7 +759,7 @@ PyObject* FemMeshPy::getccxVolumesByFace(PyObject *args) try { const TopoDS_Shape& sh = static_cast(pW)->getTopoShapePtr()->getShape(); if (sh.IsNull()) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "Face is empty"); + PyErr_SetString(PyExc_ValueError, "Face is empty"); return 0; } @@ -783,7 +777,7 @@ PyObject* FemMeshPy::getccxVolumesByFace(PyObject *args) return Py::new_reference_to(ret); } catch (Standard_Failure& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString()); + PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString()); return 0; } } @@ -817,7 +811,7 @@ PyObject* FemMeshPy::getNodesBySolid(PyObject *args) const TopoDS_Shape& sh = static_cast(pW)->getTopoShapePtr()->getShape(); const TopoDS_Solid& fc = TopoDS::Solid(sh); if (sh.IsNull()) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "Solid is empty"); + PyErr_SetString(PyExc_ValueError, "Solid is empty"); return 0; } Py::List ret; @@ -829,7 +823,7 @@ PyObject* FemMeshPy::getNodesBySolid(PyObject *args) } catch (Standard_Failure& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString()); + PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString()); return 0; } } @@ -844,7 +838,7 @@ PyObject* FemMeshPy::getNodesByFace(PyObject *args) const TopoDS_Shape& sh = static_cast(pW)->getTopoShapePtr()->getShape(); const TopoDS_Face& fc = TopoDS::Face(sh); if (sh.IsNull()) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "Face is empty"); + PyErr_SetString(PyExc_ValueError, "Face is empty"); return 0; } Py::List ret; @@ -856,7 +850,7 @@ PyObject* FemMeshPy::getNodesByFace(PyObject *args) } catch (Standard_Failure& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString()); + PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString()); return 0; } } @@ -871,7 +865,7 @@ PyObject* FemMeshPy::getNodesByEdge(PyObject *args) const TopoDS_Shape& sh = static_cast(pW)->getTopoShapePtr()->getShape(); const TopoDS_Edge& fc = TopoDS::Edge(sh); if (sh.IsNull()) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "Edge is empty"); + PyErr_SetString(PyExc_ValueError, "Edge is empty"); return 0; } Py::List ret; @@ -883,7 +877,7 @@ PyObject* FemMeshPy::getNodesByEdge(PyObject *args) } catch (Standard_Failure& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString()); + PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString()); return 0; } } @@ -898,7 +892,7 @@ PyObject* FemMeshPy::getNodesByVertex(PyObject *args) const TopoDS_Shape& sh = static_cast(pW)->getTopoShapePtr()->getShape(); const TopoDS_Vertex& fc = TopoDS::Vertex(sh); if (sh.IsNull()) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "Vertex is empty"); + PyErr_SetString(PyExc_ValueError, "Vertex is empty"); return 0; } Py::List ret; @@ -910,7 +904,7 @@ PyObject* FemMeshPy::getNodesByVertex(PyObject *args) } catch (Standard_Failure& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString()); + PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString()); return 0; } } @@ -931,7 +925,7 @@ PyObject* FemMeshPy::getElementNodes(PyObject *args) return Py::new_reference_to(ret); } catch (Standard_Failure& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString()); + PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString()); return 0; } } @@ -1029,7 +1023,7 @@ PyObject* FemMeshPy::addGroup(PyObject *args) retId = getFemMeshPtr()->addGroup(EncodedTypeString, EncodedName, theId); } catch (Standard_Failure& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString()); + PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString()); return 0; } std::cout << "Added Group: Name: \'" << EncodedName << "\' Type: \'" << EncodedTypeString << "\' id: " << retId << std::endl; @@ -1076,7 +1070,7 @@ PyObject* FemMeshPy::addGroupElements(PyObject *args) getFemMeshPtr()->addGroupElements(id, int_ids); } catch (Standard_Failure& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString()); + PyErr_SetString(Base::PyExc_FC_CADKernelError, e.GetMessageString()); return 0; } diff --git a/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp b/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp index fcbc2fe25b..0caf73c326 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp @@ -78,7 +78,7 @@ PyObject* ViewProviderFemMeshPy::setNodeColorByScalars(PyObject *args) std::vector values; int num_items = PyList_Size(node_ids_py); if (num_items < 0) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "PyList_Size < 0. That is not a valid list!"); + PyErr_SetString(PyExc_ValueError, "PyList_Size < 0. That is not a valid list!"); Py_Return; } std::vector node_colors(num_items); @@ -99,7 +99,7 @@ PyObject* ViewProviderFemMeshPy::setNodeColorByScalars(PyObject *args) node_colors[i] = calcColor(*it, min, max); this->getViewProviderFemMeshPtr()->setColorByNodeId(ids, node_colors); } else { - PyErr_SetString(Base::BaseExceptionFreeCADError, "PyArg_ParseTuple failed. Invalid arguments used with setNodeByScalars"); + PyErr_SetString(PyExc_TypeError, "PyArg_ParseTuple failed. Invalid arguments used with setNodeByScalars"); return 0; } Py_Return; @@ -124,7 +124,7 @@ PyObject* ViewProviderFemMeshPy::setNodeDisplacementByVectors(PyObject *args) std::vector vectors; int num_items = PyList_Size(node_ids_py); if (num_items < 0) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "PyList_Size < 0. That is not a valid list!"); + PyErr_SetString(PyExc_ValueError, "PyList_Size < 0. That is not a valid list!"); Py_Return; } for (int i=0; igetViewProviderFemMeshPtr()->setDisplacementByNodeId(ids, vectors); } else { - PyErr_SetString(Base::BaseExceptionFreeCADError, "PyArg_ParseTuple failed. Invalid arguments used with setNodeDisplacementByVectors"); + PyErr_SetString(PyExc_TypeError, "PyArg_ParseTuple failed. Invalid arguments used with setNodeDisplacementByVectors"); return 0; } Py_Return; diff --git a/src/Mod/Import/App/AppImportPy.cpp b/src/Mod/Import/App/AppImportPy.cpp index c5edf0367a..6c327b2ea1 100644 --- a/src/Mod/Import/App/AppImportPy.cpp +++ b/src/Mod/Import/App/AppImportPy.cpp @@ -234,7 +234,7 @@ private: } } else { - throw Py::Exception(Base::BaseExceptionFreeCADError, "no supported file format"); + throw Py::Exception(PyExc_IOError, "no supported file format"); } #if 1 @@ -278,7 +278,8 @@ private: throw Py::Exception(Base::BaseExceptionFreeCADError, e.GetMessageString()); } catch (const Base::Exception& e) { - throw Py::RuntimeError(e.what()); + e.setPyException(); + throw Py::Exception(); } return Py::None(); @@ -398,7 +399,8 @@ private: throw Py::Exception(Base::BaseExceptionFreeCADError, e.GetMessageString()); } catch (const Base::Exception& e) { - throw Py::RuntimeError(e.what()); + e.setPyException(); + throw Py::Exception(); } return Py::None(); diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index 884fc2698a..3c99c19465 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -501,7 +501,7 @@ private: aReader.SetNameMode(true); aReader.SetLayerMode(true); if (aReader.ReadFile((const char*)name8bit.c_str()) != IFSelect_RetDone) { - throw Py::Exception(Base::BaseExceptionFreeCADError, "cannot read IGES file"); + throw Py::Exception(PyExc_IOError, "cannot read IGES file"); } #if OCC_VERSION_HEX < 0x070500 @@ -527,7 +527,7 @@ private: } } else { - throw Py::Exception(Base::BaseExceptionFreeCADError, "no supported file format"); + throw Py::Exception(PyExc_IOError, "no supported file format"); } FC_DURATION_PLUS(d1,t); @@ -559,7 +559,8 @@ private: throw Py::Exception(Base::BaseExceptionFreeCADError, e.GetMessageString()); } catch (const Base::Exception& e) { - throw Py::RuntimeError(e.what()); + e.setPyException(); + throw Py::Exception(); } return Py::None(); @@ -715,7 +716,8 @@ private: throw Py::Exception(Base::BaseExceptionFreeCADError, e.GetMessageString()); } catch (const Base::Exception& e) { - throw Py::RuntimeError(e.what()); + e.setPyException(); + throw Py::Exception(); } return Py::None(); @@ -785,7 +787,7 @@ private: ->SetModel(new IGESData_IGESModel); } else { - throw Py::Exception(Base::BaseExceptionFreeCADError, "no supported file format"); + throw Py::Exception(PyExc_IOError, "no supported file format"); } static QPointer dlg = 0; @@ -818,7 +820,8 @@ private: throw Py::Exception(Base::BaseExceptionFreeCADError, e.GetMessageString()); } catch (const Base::Exception& e) { - throw Py::RuntimeError(e.what()); + e.setPyException(); + throw Py::Exception(); } return Py::None(); diff --git a/src/Mod/Mesh/App/AppMeshPy.cpp b/src/Mod/Mesh/App/AppMeshPy.cpp index bb21717a31..17786526be 100644 --- a/src/Mod/Mesh/App/AppMeshPy.cpp +++ b/src/Mod/Mesh/App/AppMeshPy.cpp @@ -274,7 +274,7 @@ private: } else { std::string exStr("Can't determine mesh format from file name: '"); exStr += outputFileName + "'"; - throw Py::Exception(Base::BaseExceptionFreeCADError, exStr.c_str()); + throw Py::ValueError(exStr.c_str()); } for (auto it : objectList) { @@ -335,7 +335,7 @@ private: } while (false); if (!mesh) { - throw Py::Exception(Base::BaseExceptionFreeCADError, "Creation of box failed"); + throw Py::RuntimeError("Creation of box failed"); } return Py::asObject(new MeshPy(mesh)); } @@ -368,7 +368,7 @@ private: MeshObject* mesh = MeshObject::createSphere(radius, sampling); if (!mesh) { - throw Py::Exception(Base::BaseExceptionFreeCADError, "Creation of sphere failed"); + throw Py::RuntimeError("Creation of sphere failed"); } return Py::asObject(new MeshPy(mesh)); } @@ -382,7 +382,7 @@ private: MeshObject* mesh = MeshObject::createEllipsoid(radius1, radius2, sampling); if (!mesh) { - throw Py::Exception(Base::BaseExceptionFreeCADError, "Creation of ellipsoid failed"); + throw Py::RuntimeError("Creation of ellipsoid failed"); } return Py::asObject(new MeshPy(mesh)); } @@ -398,7 +398,7 @@ private: MeshObject* mesh = MeshObject::createCylinder(radius, length, closed, edgelen, sampling); if (!mesh) { - throw Py::Exception(Base::BaseExceptionFreeCADError, "Creation of cylinder failed"); + throw Py::RuntimeError("Creation of cylinder failed"); } return Py::asObject(new MeshPy(mesh)); } @@ -415,7 +415,7 @@ private: MeshObject* mesh = MeshObject::createCone(radius1, radius2, len, closed, edgelen, sampling); if (!mesh) { - throw Py::Exception(Base::BaseExceptionFreeCADError, "Creation of cone failed"); + throw Py::RuntimeError("Creation of cone failed"); } return Py::asObject(new MeshPy(mesh)); } @@ -429,7 +429,7 @@ private: MeshObject* mesh = MeshObject::createTorus(radius1, radius2, sampling); if (!mesh) { - throw Py::Exception(Base::BaseExceptionFreeCADError, "Creation of torus failed"); + throw Py::RuntimeError("Creation of torus failed"); } return Py::asObject(new MeshPy(mesh)); } diff --git a/src/Mod/Mesh/App/MeshFeaturePyImp.cpp b/src/Mod/Mesh/App/MeshFeaturePyImp.cpp index 1035beeda1..1190a3a36b 100644 --- a/src/Mod/Mesh/App/MeshFeaturePyImp.cpp +++ b/src/Mod/Mesh/App/MeshFeaturePyImp.cpp @@ -180,7 +180,7 @@ PyObject* MeshFeaturePy::fixSelfIntersections(PyObject *args) obj->Mesh.finishEditing(); } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return nullptr; } Py_Return; @@ -197,7 +197,7 @@ PyObject* MeshFeaturePy::removeFoldsOnSurface(PyObject *args) obj->Mesh.finishEditing(); } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return nullptr; } Py_Return; @@ -214,7 +214,7 @@ PyObject* MeshFeaturePy::removeInvalidPoints(PyObject *args) obj->Mesh.finishEditing(); } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return nullptr; } Py_Return; diff --git a/src/Mod/Mesh/App/MeshPyImp.cpp b/src/Mod/Mesh/App/MeshPyImp.cpp index 093e599208..d189bb561d 100644 --- a/src/Mod/Mesh/App/MeshPyImp.cpp +++ b/src/Mod/Mesh/App/MeshPyImp.cpp @@ -98,7 +98,7 @@ int MeshPy::PyInit(PyObject* args, PyObject*) } } catch (const Base::Exception &e) { - PyErr_SetString(Base::BaseExceptionFreeCADError,e.what()); + e.setPyException(); return -1; } catch (const std::exception &e) { @@ -643,7 +643,7 @@ PyObject* MeshPy::addFacet(PyObject *args) Py_Return; } - PyErr_SetString(Base::BaseExceptionFreeCADError, "set 9 floats or three vectors or a facet"); + PyErr_SetString(PyExc_TypeError, "set 9 floats or three vectors or a facet"); return nullptr; } @@ -690,7 +690,7 @@ PyObject* MeshPy::addFacets(PyObject *args) } } else { - PyErr_SetString(Base::BaseExceptionFreeCADError, "expect a sequence of floats or Vector"); + PyErr_SetString(PyExc_TypeError, "expect a sequence of floats or Vector"); return nullptr; } @@ -746,7 +746,7 @@ PyObject* MeshPy::addFacets(PyObject *args) Py_Return; } - PyErr_SetString(Base::BaseExceptionFreeCADError, "either expect\n" + PyErr_SetString(PyExc_TypeError, "either expect\n" "-- [Vector] (3 of them define a facet)\n" "-- ([Vector],[(int,int,int)])"); return nullptr; @@ -1069,7 +1069,7 @@ PyObject* MeshPy::fixSelfIntersections(PyObject *args) getMeshObjectPtr()->removeSelfIntersections(); } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return nullptr; } Py_Return; @@ -1083,7 +1083,7 @@ PyObject* MeshPy::removeFoldsOnSurface(PyObject *args) getMeshObjectPtr()->removeFoldsOnSurface(); } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return nullptr; } Py_Return; @@ -1105,7 +1105,7 @@ PyObject* MeshPy::removeInvalidPoints(PyObject *args) getMeshObjectPtr()->removeInvalidPoints(); } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return nullptr; } Py_Return; @@ -1129,7 +1129,7 @@ PyObject* MeshPy::removePointsOnEdge(PyObject *args, PyObject *kwds) getMeshObjectPtr()->removePointsOnEdge(PyObject_IsTrue(fillBoundary) ? true : false); } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return nullptr; } Py_Return; @@ -1240,7 +1240,7 @@ PyObject* MeshPy::fillupHoles(PyObject *args) getMeshObjectPtr()->fillupHoles(len, level, *tria); } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return nullptr; } diff --git a/src/Mod/MeshPart/App/AppMeshPartPy.cpp b/src/Mod/MeshPart/App/AppMeshPartPy.cpp index e3766ef08c..f0caaa0abf 100644 --- a/src/Mod/MeshPart/App/AppMeshPartPy.cpp +++ b/src/Mod/MeshPart/App/AppMeshPartPy.cpp @@ -197,24 +197,24 @@ private: auto exText( "List of Tuples of three or two floats needed as second parameter!" ); if (!PyList_Check(pcListObj)) - throw Py::Exception(Base::BaseExceptionFreeCADError, exText); + throw Py::TypeError(exText); int nSize = PyList_Size(pcListObj); for (int i=0; isetShape(fm->Face()); return 0; - } catch (Base::Exception &e){ - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + } catch (Base::Exception &e) { + e.setPyException(); return -1; } catch (Standard_Failure& e){ PyErr_SetString(PartExceptionOCCError, e.GetMessageString()); diff --git a/src/Mod/Part/Gui/AttacherTexts.cpp b/src/Mod/Part/Gui/AttacherTexts.cpp index 5480ef61a7..cf8e0f5194 100644 --- a/src/Mod/Part/Gui/AttacherTexts.cpp +++ b/src/Mod/Part/Gui/AttacherTexts.cpp @@ -394,7 +394,7 @@ PyObject* AttacherGuiPy::sGetModeStrings(PyObject * /*self*/, PyObject *args) } catch (const Py::Exception&) { return 0; } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return 0; } } @@ -411,7 +411,7 @@ PyObject* AttacherGuiPy::sGetRefTypeUserFriendlyName(PyObject * /*self*/, PyObje } catch (const Py::Exception&) { return 0; } catch (const Base::Exception& e) { - PyErr_SetString(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); return 0; } } diff --git a/src/Mod/Path/App/PathPyImp.cpp b/src/Mod/Path/App/PathPyImp.cpp index 3a6e3e94bf..c06376f318 100644 --- a/src/Mod/Path/App/PathPyImp.cpp +++ b/src/Mod/Path/App/PathPyImp.cpp @@ -164,7 +164,7 @@ PyObject* PathPy::addCommands(PyObject * args) } return new PathPy(new Path::Toolpath(*getToolpathPtr())); } - Py_Error(Base::BaseExceptionFreeCADError, "Wrong parameters - command or list of commands expected"); + Py_Error(PyExc_TypeError, "Wrong parameters - command or list of commands expected"); } PyObject* PathPy::insertCommand(PyObject * args) @@ -176,7 +176,7 @@ PyObject* PathPy::insertCommand(PyObject * args) getToolpathPtr()->insertCommand(cmd,pos); return new PathPy(new Path::Toolpath(*getToolpathPtr())); } - Py_Error(Base::BaseExceptionFreeCADError, "Wrong parameters - expected command and optional integer"); + Py_Error(PyExc_TypeError, "Wrong parameters - expected command and optional integer"); } PyObject* PathPy::deleteCommand(PyObject * args) @@ -186,7 +186,7 @@ PyObject* PathPy::deleteCommand(PyObject * args) getToolpathPtr()->deleteCommand(pos); return new PathPy(new Path::Toolpath(*getToolpathPtr())); } - Py_Error(Base::BaseExceptionFreeCADError, "Wrong parameters - expected an integer (optional)"); + Py_Error(PyExc_TypeError, "Wrong parameters - expected an integer (optional)"); } PyObject* PathPy::getCycleTime(PyObject * args) diff --git a/src/Mod/Path/App/TooltablePyImp.cpp b/src/Mod/Path/App/TooltablePyImp.cpp index 1facaab295..6b4b4ec3a9 100644 --- a/src/Mod/Path/App/TooltablePyImp.cpp +++ b/src/Mod/Path/App/TooltablePyImp.cpp @@ -171,7 +171,7 @@ PyObject* TooltablePy::addTools(PyObject * args) Py_INCREF(Py_None); return Py_None; } - Py_Error(Base::BaseExceptionFreeCADError, "Wrong parameters - tool or list of tools expected"); + Py_Error(PyExc_TypeError, "Wrong parameters - tool or list of tools expected"); } PyObject* TooltablePy::setTool(PyObject * args) @@ -185,7 +185,7 @@ PyObject* TooltablePy::setTool(PyObject * args) Py_INCREF(Py_None); return Py_None; } - Py_Error(Base::BaseExceptionFreeCADError, "Wrong parameters - expected tool and optional integer"); + Py_Error(PyExc_TypeError, "Wrong parameters - expected tool and optional integer"); } PyObject* TooltablePy::getTool(PyObject * args) @@ -203,7 +203,7 @@ PyObject* TooltablePy::getTool(PyObject * args) return Py_None; } } - Py_Error(Base::BaseExceptionFreeCADError, "Argument must be integer"); + Py_Error(PyExc_TypeError, "Argument must be integer"); } PyObject* TooltablePy::deleteTool(PyObject * args) @@ -215,7 +215,7 @@ PyObject* TooltablePy::deleteTool(PyObject * args) Py_INCREF(Py_None); return Py_None; } - Py_Error(Base::BaseExceptionFreeCADError, "Wrong parameters - expected an integer (optional)"); + Py_Error(PyExc_TypeError, "Wrong parameters - expected an integer (optional)"); } // custom attributes get/set diff --git a/src/Mod/Points/App/PointsPyImp.cpp b/src/Mod/Points/App/PointsPyImp.cpp index 06a193b855..f26f20310d 100644 --- a/src/Mod/Points/App/PointsPyImp.cpp +++ b/src/Mod/Points/App/PointsPyImp.cpp @@ -160,7 +160,7 @@ PyObject* PointsPy::addPoints(PyObject * args) } } catch (const Py::Exception&) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "either expect\n" + PyErr_SetString(PyExc_TypeError, "either expect\n" "-- [Vector,...] \n" "-- [(x,y,z),...]"); return nullptr; @@ -190,7 +190,7 @@ PyObject* PointsPy::fromSegment(PyObject * args) return new PointsPy(pts.release()); } catch (const Py::Exception&) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "expect a list of int"); + PyErr_SetString(PyExc_TypeError, "expect a list of int"); return nullptr; } } @@ -212,7 +212,7 @@ PyObject* PointsPy::fromValid(PyObject * args) return new PointsPy(pts.release()); } catch (const Py::Exception&) { - PyErr_SetString(Base::BaseExceptionFreeCADError, "expect a list of int"); + PyErr_SetString(PyExc_TypeError, "expect a list of int"); return nullptr; } } diff --git a/src/Mod/Robot/App/TrajectoryPyImp.cpp b/src/Mod/Robot/App/TrajectoryPyImp.cpp index ac075fbc15..05838a2de6 100644 --- a/src/Mod/Robot/App/TrajectoryPyImp.cpp +++ b/src/Mod/Robot/App/TrajectoryPyImp.cpp @@ -111,7 +111,7 @@ PyObject* TrajectoryPy::insertWaypoints(PyObject * args) return new TrajectoryPy(new Robot::Trajectory(*getTrajectoryPtr())); } - Py_Error(Base::BaseExceptionFreeCADError, "Wrong parameters - waypoint or placement expected"); + Py_Error(PyExc_TypeError, "Wrong parameters - waypoint or placement expected"); } diff --git a/src/Mod/TechDraw/App/AppTechDrawPy.cpp b/src/Mod/TechDraw/App/AppTechDrawPy.cpp index 7cf65a4fdb..886d183c16 100644 --- a/src/Mod/TechDraw/App/AppTechDrawPy.cpp +++ b/src/Mod/TechDraw/App/AppTechDrawPy.cpp @@ -284,7 +284,8 @@ private: } } catch (Base::Exception &e) { - throw Py::Exception(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); + throw Py::Exception(); } return result; } @@ -334,7 +335,8 @@ private: } } catch (Base::Exception &e) { - throw Py::Exception(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); + throw Py::Exception(); } if (!success) { return Py::None(); @@ -400,7 +402,8 @@ private: } } catch (Base::Exception &e) { - throw Py::Exception(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); + throw Py::Exception(); } if (!success) { return Py::None(); @@ -457,7 +460,8 @@ private: } } catch (Base::Exception &e) { - throw Py::Exception(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); + throw Py::Exception(); } return dxfReturn; @@ -535,7 +539,8 @@ private: } } catch (Base::Exception &e) { - throw Py::Exception(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); + throw Py::Exception(); } return svgReturn; @@ -1011,7 +1016,8 @@ private: } } catch (Base::Exception &e) { - throw Py::Exception(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); + throw Py::Exception(); } return result; */ @@ -1029,7 +1035,8 @@ private: } } catch (Base::Exception &e) { - throw Py::Exception(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); + throw Py::Exception(); } PyObject* pycomp = new TopoShapeCompoundPy(new TopoShape(comp)); return Py::asObject(pycomp); diff --git a/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp b/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp index e470151c36..2f1a97f792 100644 --- a/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp +++ b/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp @@ -204,7 +204,8 @@ private: } } catch (Base::Exception &e) { - throw Py::Exception(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); + throw Py::Exception(); } return Py::None(); @@ -249,7 +250,8 @@ private: } } catch (Base::Exception &e) { - throw Py::Exception(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); + throw Py::Exception(); } return Py::None(); @@ -310,7 +312,8 @@ private: } } catch (Base::Exception &e) { - throw Py::Exception(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); + throw Py::Exception(); } PyObject* pyResult = nullptr; @@ -356,7 +359,8 @@ private: } } catch (Base::Exception &e) { - throw Py::Exception(Base::BaseExceptionFreeCADError, e.what()); + e.setPyException(); + throw Py::Exception(); } return Py::None();