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

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