Py: replace BaseExceptionFreeCADError with more suitable exception types

This commit is contained in:
wmayer
2022-03-17 13:54:23 +01:00
parent 18847444d4
commit 1f12dca2b4
38 changed files with 148 additions and 133 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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();
}
}

View File

@@ -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());

View File

@@ -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;
}
}