Replace Base::Exception with appropriate subclass
This commit is contained in:
@@ -268,7 +268,7 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::v
|
||||
TechDrawGeometry::BaseGeom* base = BaseGeom::baseFactory(e);
|
||||
if (base == nullptr) {
|
||||
Base::Console().Log("FAIL - DGH::getTrimmedLines - baseFactory failed for edge: %d\n",i);
|
||||
throw Base::Exception("DGH::getTrimmedLines - baseFactory failed");
|
||||
throw Base::ValueError("DGH::getTrimmedLines - baseFactory failed");
|
||||
}
|
||||
resultGeoms.push_back(base);
|
||||
i++;
|
||||
@@ -416,7 +416,7 @@ std::vector<LineSet> DrawGeomHatch::getFaceOverlay(int fdx)
|
||||
TechDrawGeometry::BaseGeom* base = BaseGeom::baseFactory(e);
|
||||
if (base == nullptr) {
|
||||
Base::Console().Log("FAIL - DGH::getFaceOverlay - baseFactory failed for edge: %d\n",i);
|
||||
throw Base::Exception("DGH::getFaceOverlay - baseFactory failed");
|
||||
throw Base::ValueError("DGH::getFaceOverlay - baseFactory failed");
|
||||
}
|
||||
resultGeoms.push_back(base);
|
||||
i++;
|
||||
|
||||
@@ -214,7 +214,7 @@ double DrawPage::getPageWidth() const
|
||||
return templ->getWidth();
|
||||
}
|
||||
|
||||
throw Base::Exception("Template not set for Page");
|
||||
throw Base::RuntimeError("Template not set for Page");
|
||||
}
|
||||
|
||||
double DrawPage::getPageHeight() const
|
||||
@@ -229,7 +229,7 @@ double DrawPage::getPageHeight() const
|
||||
}
|
||||
}
|
||||
|
||||
throw Base::Exception("Template not set for Page");
|
||||
throw Base::RuntimeError("Template not set for Page");
|
||||
}
|
||||
|
||||
const char * DrawPage::getPageOrientation() const
|
||||
@@ -244,7 +244,7 @@ const char * DrawPage::getPageOrientation() const
|
||||
return templ->Orientation.getValueAsString();
|
||||
}
|
||||
}
|
||||
throw Base::Exception("Template not set for Page");
|
||||
throw Base::RuntimeError("Template not set for Page");
|
||||
}
|
||||
|
||||
int DrawPage::addView(App::DocumentObject *docObj)
|
||||
|
||||
@@ -74,12 +74,12 @@ unsigned int DrawParametricTemplate::getMemSize(void) const
|
||||
}
|
||||
|
||||
double DrawParametricTemplate::getWidth() const {
|
||||
throw Base::Exception("Need to Implement");
|
||||
throw Base::NotImplementedError("Need to Implement");
|
||||
}
|
||||
|
||||
|
||||
double DrawParametricTemplate::getHeight() const {
|
||||
throw Base::Exception("Need to Implement");
|
||||
throw Base::NotImplementedError("Need to Implement");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ double DrawProjGroup::calculateAutomaticScale() const
|
||||
{
|
||||
TechDraw::DrawPage *page = getPage();
|
||||
if (page == NULL)
|
||||
throw Base::Exception("No page is assigned to this feature");
|
||||
throw Base::RuntimeError("No page is assigned to this feature");
|
||||
|
||||
DrawProjGroupItem *viewPtrs[10];
|
||||
|
||||
@@ -404,7 +404,7 @@ int DrawProjGroup::removeProjection(const char *viewProjType)
|
||||
// TODO: shouldn't be able to delete "Front" unless deleting whole group
|
||||
if ( checkViewProjType(viewProjType) ) {
|
||||
if( !hasProjection(viewProjType) ) {
|
||||
throw Base::Exception("The projection doesn't exist in the group");
|
||||
throw Base::RuntimeError("The projection doesn't exist in the group");
|
||||
}
|
||||
|
||||
// Iterate through the child views and find the projection type
|
||||
@@ -676,10 +676,10 @@ int DrawProjGroup::getViewIndex(const char *viewTypeCStr) const
|
||||
} else if (strcmp(viewTypeCStr, "FrontBottomRight") == 0) {
|
||||
result = thirdAngle ? 9 : 0;
|
||||
} else {
|
||||
throw Base::Exception("Unknown view type in DrawProjGroup::getViewIndex()");
|
||||
throw Base::TypeError("Unknown view type in DrawProjGroup::getViewIndex()");
|
||||
}
|
||||
} else {
|
||||
throw Base::Exception("Unknown Projection convention in DrawProjGroup::getViewIndex()");
|
||||
throw Base::ValueError("Unknown Projection convention in DrawProjGroup::getViewIndex()");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -736,12 +736,12 @@ void DrawProjGroup::arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const
|
||||
} else if (strcmp(viewTypeCStr, "FrontBottomRight") == 0) {
|
||||
viewPtrs[thirdAngle ? 9 : 0] = oView;
|
||||
} else {
|
||||
throw Base::Exception("Unknown view type in DrawProjGroup::arrangeViewPointers()");
|
||||
throw Base::TypeError("Unknown view type in DrawProjGroup::arrangeViewPointers()");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw Base::Exception("Unknown view type in DrawProjGroup::arrangeViewPointers()");
|
||||
throw Base::ValueError("Unknown view type in DrawProjGroup::arrangeViewPointers()");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ App::DocumentObjectExecReturn *DrawTemplate::execute(void)
|
||||
|
||||
void DrawTemplate::getBlockDimensions(double & /*x*/, double & /*y*/, double & /*width*/, double & /*height*/) const
|
||||
{
|
||||
throw Base::Exception("implement in virtual function");
|
||||
throw Base::NotImplementedError("implement in virtual function");
|
||||
}
|
||||
|
||||
DrawPage* DrawTemplate::getParentPage() const
|
||||
|
||||
@@ -87,10 +87,10 @@ using namespace TechDraw;
|
||||
return int (std::strtol(what.str().c_str(), &endChar, 10)); //TODO: use std::stoi() in c++11
|
||||
} else {
|
||||
ErrorMsg << "getIndexFromName: malformed geometry name - " << geomName;
|
||||
throw Base::Exception(ErrorMsg.str());
|
||||
throw Base::ValueError(ErrorMsg.str());
|
||||
}
|
||||
} else {
|
||||
throw Base::Exception("getIndexFromName - empty geometry name");
|
||||
throw Base::ValueError("getIndexFromName - empty geometry name");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,10 +108,10 @@ std::string DrawUtil::getGeomTypeFromName(std::string geomName)
|
||||
return what.str(); //TODO: use std::stoi() in c++11
|
||||
} else {
|
||||
ErrorMsg << "In getGeomTypeFromName: malformed geometry name - " << geomName;
|
||||
throw Base::Exception(ErrorMsg.str());
|
||||
throw Base::ValueError(ErrorMsg.str());
|
||||
}
|
||||
} else {
|
||||
throw Base::Exception("getGeomTypeFromName - empty geometry name");
|
||||
throw Base::ValueError("getGeomTypeFromName - empty geometry name");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ QRectF DrawViewCollection::getRect() const
|
||||
for (auto& v:Views.getValues()) {
|
||||
TechDraw::DrawView *view = dynamic_cast<TechDraw::DrawView *>(v);
|
||||
if (!view) {
|
||||
throw Base::Exception("DrawViewCollection::getRect bad View\n");
|
||||
throw Base::ValueError("DrawViewCollection::getRect bad View\n");
|
||||
}
|
||||
|
||||
result = result.united(view->getRect().translated(view->X.getValue(),view->Y.getValue()));
|
||||
|
||||
@@ -561,7 +561,7 @@ double DrawViewDimension::getDimValue()
|
||||
} else if(Type.isValue("Angle")){
|
||||
result = measurement->angle();
|
||||
} else { //tarfu
|
||||
throw Base::Exception("getDimValue() - Unknown Dimension Type (3)");
|
||||
throw Base::ValueError("getDimValue() - Unknown Dimension Type (3)");
|
||||
}
|
||||
} else {
|
||||
// Projected Values
|
||||
@@ -793,7 +793,7 @@ pointPair DrawViewDimension::closestPoints(TopoDS_Shape s1,
|
||||
pointPair result;
|
||||
BRepExtrema_DistShapeShape extss(s1, s2);
|
||||
if (!extss.IsDone()) {
|
||||
throw Base::Exception("DVD::closestPoints - BRepExtrema_DistShapeShape failed");
|
||||
throw Base::RuntimeError("DVD::closestPoints - BRepExtrema_DistShapeShape failed");
|
||||
}
|
||||
int count = extss.NbSolution();
|
||||
if (count != 0) {
|
||||
@@ -860,7 +860,7 @@ double DrawViewDimension::dist2Segs(Base::Vector2d s1,
|
||||
|
||||
BRepExtrema_DistShapeShape extss(edge1, edge2);
|
||||
if (!extss.IsDone()) {
|
||||
throw Base::Exception("DVD::dist2Segs - BRepExtrema_DistShapeShape failed");
|
||||
throw Base::RuntimeError("DVD::dist2Segs - BRepExtrema_DistShapeShape failed");
|
||||
}
|
||||
int count = extss.NbSolution();
|
||||
double minDist = 0.0;
|
||||
|
||||
@@ -390,7 +390,7 @@ TopoDS_Face DrawViewSection::projectFace(const TopoDS_Shape &face,
|
||||
const Base::Vector3d &direction)
|
||||
{
|
||||
if(face.IsNull()) {
|
||||
throw Base::Exception("DrawViewSection::projectFace - input Face is NULL");
|
||||
throw Base::ValueError("DrawViewSection::projectFace - input Face is NULL");
|
||||
}
|
||||
|
||||
Base::Vector3d origin(faceCenter.X(),faceCenter.Y(),faceCenter.Z());
|
||||
|
||||
@@ -132,7 +132,7 @@ bool EdgeWalker::loadEdges(std::vector<TopoDS_Edge> edges)
|
||||
{
|
||||
//Base::Console().Message("TRACE -EW::loadEdges(TopoDS)\n");
|
||||
if (edges.empty()) {
|
||||
throw Base::Exception("EdgeWalker has no edges to load\n");
|
||||
throw Base::ValueError("EdgeWalker has no edges to load\n");
|
||||
}
|
||||
|
||||
std::vector<TopoDS_Vertex> verts = makeUniqueVList(edges);
|
||||
|
||||
@@ -483,7 +483,7 @@ Base::Vector2d Generic::apparentInter(Generic* g)
|
||||
// Line Intersetion (taken from ViewProviderSketch.cpp)
|
||||
double det = dir0.x*dir1.y - dir0.y*dir1.x;
|
||||
if ((det > 0 ? det : -det) < 1e-10)
|
||||
throw Base::Exception("Invalid selection - Det = 0");
|
||||
throw Base::ValueError("Invalid selection - Det = 0");
|
||||
|
||||
double c0 = dir0.y*points.at(0).x - dir0.x*points.at(0).y;
|
||||
double c1 = dir1.y*g->points.at(1).x - dir1.x*g->points.at(1).y;
|
||||
|
||||
@@ -390,7 +390,7 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
|
||||
base = BaseGeom::baseFactory(edge);
|
||||
if (base == nullptr) {
|
||||
Base::Console().Message("Error - GO::addGeomFromCompound - baseFactory failed for edge: %d\n",i);
|
||||
throw Base::Exception("GeometryObject::addGeomFromCompound - baseFactory failed");
|
||||
throw Base::ValueError("GeometryObject::addGeomFromCompound - baseFactory failed");
|
||||
}
|
||||
base->classOfEdge = category;
|
||||
base->visible = visible;
|
||||
|
||||
@@ -137,7 +137,7 @@ void CmdTechDrawNewPageDef::activated(int iMsg)
|
||||
commitCommand();
|
||||
TechDraw::DrawPage* fp = dynamic_cast<TechDraw::DrawPage*>(getDocument()->getObject(PageName.c_str()));
|
||||
if (!fp) {
|
||||
throw Base::Exception("CmdTechDrawNewPageDef fp not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewPageDef fp not found\n");
|
||||
}
|
||||
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(getDocument())->getViewProvider(fp);
|
||||
@@ -217,7 +217,7 @@ void CmdTechDrawNewPage::activated(int iMsg)
|
||||
commitCommand();
|
||||
TechDraw::DrawPage* fp = dynamic_cast<TechDraw::DrawPage*>(getDocument()->getObject(PageName.c_str()));
|
||||
if (!fp) {
|
||||
throw Base::Exception("CmdTechDrawNewPagePick fp not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewPagePick fp not found\n");
|
||||
}
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(getDocument())->getViewProvider(fp);
|
||||
TechDrawGui::ViewProviderPage* dvp = dynamic_cast<TechDrawGui::ViewProviderPage*>(vp);
|
||||
@@ -309,7 +309,7 @@ void CmdTechDrawNewView::activated(int iMsg)
|
||||
App::DocumentObject *docObj = getDocument()->getObject(FeatName.c_str());
|
||||
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart *>(docObj);
|
||||
if (!dvp) {
|
||||
throw Base::Exception("CmdTechDrawNewView DVP not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewView DVP not found\n");
|
||||
}
|
||||
dvp->Source.setValues(shapes);
|
||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||
@@ -381,7 +381,7 @@ void CmdTechDrawNewViewSection::activated(int iMsg)
|
||||
App::DocumentObject *docObj = getDocument()->getObject(FeatName.c_str());
|
||||
TechDraw::DrawViewSection* dsv = dynamic_cast<TechDraw::DrawViewSection *>(docObj);
|
||||
if (!dsv) {
|
||||
throw Base::Exception("CmdTechDrawNewViewSection DVS not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewViewSection DVS not found\n");
|
||||
}
|
||||
dsv->Source.setValues(dvp->Source.getValues());
|
||||
doCommand(Doc,"App.activeDocument().%s.BaseView = App.activeDocument().%s",FeatName.c_str(),BaseName.c_str());
|
||||
@@ -449,7 +449,7 @@ void CmdTechDrawNewViewDetail::activated(int iMsg)
|
||||
App::DocumentObject *docObj = getDocument()->getObject(FeatName.c_str());
|
||||
TechDraw::DrawViewDetail* dvd = dynamic_cast<TechDraw::DrawViewDetail *>(docObj);
|
||||
if (!dvd) {
|
||||
throw Base::Exception("CmdTechDrawNewViewDetail DVD not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewViewDetail DVD not found\n");
|
||||
}
|
||||
dvd->Source.setValues(dvp->Source.getValues());
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ void CmdTechDrawNewDimension::activated(int iMsg)
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
if (!dim) {
|
||||
throw Base::Exception("CmdTechDrawNewDimension - dim not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewDimension - dim not found\n");
|
||||
}
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
@@ -310,7 +310,7 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
if (!dim) {
|
||||
throw Base::Exception("CmdTechDrawNewRadiusDimension - dim not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewRadiusDimension - dim not found\n");
|
||||
}
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
@@ -410,7 +410,7 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
if (!dim) {
|
||||
throw Base::Exception("CmdTechDrawNewDiameterDimension - dim not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewDiameterDimension - dim not found\n");
|
||||
}
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
@@ -519,7 +519,7 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
|
||||
, "Distance");
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
if (!dim) {
|
||||
throw Base::Exception("CmdTechDrawNewLengthDimension - dim not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewLengthDimension - dim not found\n");
|
||||
}
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
@@ -632,7 +632,7 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
if (!dim) {
|
||||
throw Base::Exception("CmdTechDrawNewDistanceXDimension - dim not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewDistanceXDimension - dim not found\n");
|
||||
}
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
@@ -744,7 +744,7 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
|
||||
,"DistanceY");
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
if (!dim) {
|
||||
throw Base::Exception("CmdTechDrawNewDistanceYDimension - dim not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewDistanceYDimension - dim not found\n");
|
||||
}
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
@@ -836,7 +836,7 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
if (!dim) {
|
||||
throw Base::Exception("CmdTechDrawNewAngleDimension - dim not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewAngleDimension - dim not found\n");
|
||||
}
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
@@ -925,7 +925,7 @@ void CmdTechDrawNewAngle3PtDimension::activated(int iMsg)
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
if (!dim) {
|
||||
throw Base::Exception("CmdTechDrawNewAngle3PtDimension - dim not found\n");
|
||||
throw Base::TypeError("CmdTechDrawNewAngle3PtDimension - dim not found\n");
|
||||
}
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ void QGIDrawingTemplate::draw()
|
||||
|
||||
TechDraw::DrawParametricTemplate *tmplte = getParametricTemplate();
|
||||
if(!tmplte) {
|
||||
throw Base::Exception("Template Feuature not set for QGIDrawingTemplate");
|
||||
throw Base::RuntimeError("Template Feuature not set for QGIDrawingTemplate");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ void QGISVGTemplate::draw()
|
||||
{
|
||||
TechDraw::DrawSVGTemplate *tmplte = getSVGTemplate();
|
||||
if(!tmplte)
|
||||
throw Base::Exception("Template Feature not set for QGISVGTemplate");
|
||||
throw Base::RuntimeError("Template Feature not set for QGISVGTemplate");
|
||||
load(QString::fromUtf8(tmplte->PageResult.getValue()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user