Py: replace BaseExceptionFreeCADError with more suitable exception types
This commit is contained in:
@@ -166,7 +166,7 @@ AppExport std::map<std::string,std::string> 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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ const char* AbortException::what() const throw()
|
||||
|
||||
PyObject * AbortException::getPyExceptionType() const
|
||||
{
|
||||
return BaseExceptionFreeCADAbort;
|
||||
return PyExc_FC_FreeCADAbort;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 (...) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<App::DocumentObject*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(Drawing::FeatureViewPart::getClassTypeId())) {
|
||||
Drawing::FeatureViewPart* view = static_cast<Drawing::FeatureViewPart*>(*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");
|
||||
|
||||
@@ -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<Base::PlacementPy*>(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<Base::PlacementPy*>(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<Part::TopoShapeFacePy*>(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<Part::TopoShapeEdgePy*>(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<Part::TopoShapeFacePy*>(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<Part::TopoShapeFacePy*>(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<Part::TopoShapeSolidPy*>(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<Part::TopoShapeFacePy*>(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<Part::TopoShapeEdgePy*>(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<Part::TopoShapeVertexPy*>(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;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ PyObject* ViewProviderFemMeshPy::setNodeColorByScalars(PyObject *args)
|
||||
std::vector<double> 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<App::Color> 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<Base::Vector3d> 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; i<num_items; i++){
|
||||
@@ -137,7 +137,7 @@ PyObject* ViewProviderFemMeshPy::setNodeDisplacementByVectors(PyObject *args)
|
||||
}
|
||||
this->getViewProviderFemMeshPtr()->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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<QDialog> 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();
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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; i<nSize;++i) {
|
||||
PyObject* item = PyList_GetItem(pcListObj, i);
|
||||
if (!PyTuple_Check(item))
|
||||
throw Py::Exception(Base::BaseExceptionFreeCADError, exText);
|
||||
throw Py::TypeError(exText);
|
||||
|
||||
int nTSize = PyTuple_Size(item);
|
||||
if (nTSize != 2 && nTSize != 3)
|
||||
throw Py::Exception(Base::BaseExceptionFreeCADError, exText);
|
||||
throw Py::ValueError(exText);
|
||||
|
||||
Base::Vector3f vec(0,0,0);
|
||||
|
||||
for(int l = 0; l < nTSize;l++) {
|
||||
PyObject* item2 = PyTuple_GetItem(item, l);
|
||||
if (!PyFloat_Check(item2))
|
||||
throw Py::Exception(Base::BaseExceptionFreeCADError, exText);
|
||||
throw Py::TypeError(exText);
|
||||
vec[l] = (float)PyFloat_AS_DOUBLE(item2);
|
||||
}
|
||||
poly.push_back(vec);
|
||||
@@ -632,7 +632,7 @@ private:
|
||||
return Py::asObject(new Mesh::MeshPy(mesher.createMesh()));
|
||||
}
|
||||
|
||||
throw Py::Exception(Base::BaseExceptionFreeCADError,"Wrong arguments");
|
||||
throw Py::TypeError("Wrong arguments");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -910,12 +910,13 @@ private:
|
||||
return Py::asObject(topo.getPyObject());
|
||||
}
|
||||
|
||||
throw Py::Exception(Base::BaseExceptionFreeCADError, std::string("Argument type signature not recognized. Should be either (list, string), or (shape, string)"));
|
||||
throw Py::TypeError(std::string("Argument type signature not recognized. Should be either (list, string), or (shape, string)"));
|
||||
|
||||
} catch (Standard_Failure& e) {
|
||||
throw Py::Exception(PartExceptionOCCError, e.GetMessageString());
|
||||
} catch (Base::Exception &e){
|
||||
throw Py::Exception(Base::BaseExceptionFreeCADError, e.what());
|
||||
e.setPyException();
|
||||
throw Py::Exception();
|
||||
}
|
||||
}
|
||||
Py::Object makeFilledFace(const Py::Tuple& args)
|
||||
|
||||
@@ -88,7 +88,7 @@ int AttachEnginePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "Wrong set of constructor arguments. Can be: (), ('Attacher::AttachEngine3D'), ('Attacher::AttachEnginePlane'), ('Attacher::AttachEngineLine'), ('Attacher::AttachEnginePoint'), (other_attacher_instance).");
|
||||
PyErr_SetString(PyExc_TypeError, "Wrong set of constructor arguments. Can be: (), ('Attacher::AttachEngine3D'), ('Attacher::AttachEnginePlane'), ('Attacher::AttachEngineLine'), ('Attacher::AttachEnginePoint'), (other_attacher_instance).");
|
||||
return -1;
|
||||
|
||||
}
|
||||
@@ -108,7 +108,8 @@ Py::String AttachEnginePy::getAttacherType(void) const
|
||||
catch (Standard_Failure& e) {\
|
||||
throw Py::Exception(Part::PartExceptionOCCError, e.GetMessageString());\
|
||||
} catch (Base::Exception &e) {\
|
||||
throw Py::Exception(Base::BaseExceptionFreeCADError, e.what());\
|
||||
e.setPyException();\
|
||||
throw Py::Exception();\
|
||||
}
|
||||
|
||||
Py::String AttachEnginePy::getMode(void) const
|
||||
|
||||
@@ -29,7 +29,7 @@ PyObject* AttachExtensionPy::positionBySupport(PyObject *args)
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return NULL;
|
||||
} catch (Base::Exception &e) {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
|
||||
e.setPyException();
|
||||
return NULL;
|
||||
}
|
||||
return Py::new_reference_to(Py::Boolean(bAttached));
|
||||
@@ -47,7 +47,7 @@ PyObject* AttachExtensionPy::changeAttacherType(PyObject *args)
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return NULL;
|
||||
} catch (Base::Exception &e) {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
|
||||
e.setPyException();
|
||||
return NULL;
|
||||
}
|
||||
return Py::new_reference_to(Py::Boolean(ret));
|
||||
@@ -66,7 +66,8 @@ Py::Object AttachExtensionPy::getAttacher(void) const
|
||||
} catch (Standard_Failure& e) {
|
||||
throw Py::Exception(Part::PartExceptionOCCError, e.GetMessageString());
|
||||
} catch (Base::Exception &e) {
|
||||
throw Py::Exception(Base::BaseExceptionFreeCADError, e.what());
|
||||
e.setPyException();
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -363,8 +363,8 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
getTopoShapePtr()->setShape(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());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user