From 00de5bb7ad1d2ebc2d484ab78fe69e86d451749e Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 14 Nov 2018 19:28:00 +0100 Subject: [PATCH] Replace Base::Exception with appropriate subclass --- src/Mod/PartDesign/App/Body.cpp | 4 +- src/Mod/PartDesign/App/Feature.cpp | 14 ++-- src/Mod/PartDesign/App/FeatureDraft.cpp | 30 ++++---- src/Mod/PartDesign/App/FeatureDressUp.cpp | 2 +- src/Mod/PartDesign/App/FeatureGroove.cpp | 2 +- .../PartDesign/App/FeatureLinearPattern.cpp | 26 +++---- src/Mod/PartDesign/App/FeatureMirrored.cpp | 12 ++-- .../PartDesign/App/FeatureMultiTransform.cpp | 8 +-- src/Mod/PartDesign/App/FeaturePipe.cpp | 10 +-- .../PartDesign/App/FeaturePolarPattern.cpp | 18 ++--- src/Mod/PartDesign/App/FeatureRevolution.cpp | 3 +- src/Mod/PartDesign/App/FeatureScaled.cpp | 4 +- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 68 +++++++++---------- src/Mod/PartDesign/App/FeatureTransformed.cpp | 2 +- .../PartDesign/Gui/TaskFeatureParameters.cpp | 4 +- src/Mod/PartDesign/Gui/TaskPipeParameters.cpp | 2 +- src/Mod/PartDesign/Gui/TaskShapeBinder.cpp | 2 +- .../Gui/TaskSketchBasedParameters.cpp | 2 +- .../Gui/TaskTransformedParameters.cpp | 4 +- src/Mod/PartDesign/Gui/Utils.cpp | 6 +- src/Mod/PartDesign/Gui/ViewProvider.cpp | 4 +- src/Mod/PartDesign/Gui/ViewProviderBody.cpp | 2 +- src/Mod/PartDesign/Gui/WorkflowManager.cpp | 2 +- 23 files changed, 116 insertions(+), 115 deletions(-) diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index 5d8818cb46..849ccd381b 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -266,7 +266,7 @@ Body* Body::findBodyOf(const App::DocumentObject* feature) std::vector Body::addObject(App::DocumentObject *feature) { if(!isAllowed(feature)) - throw Base::Exception("Body: object is not allowed"); + throw Base::ValueError("Body: object is not allowed"); //TODO: features should not add all links @@ -299,7 +299,7 @@ std::vector< App::DocumentObject* > Body::addObjects(std::vector< App::DocumentO void Body::insertObject(App::DocumentObject* feature, App::DocumentObject* target, bool after) { if (target && !hasObject (target)) { - throw Base::Exception("Body: the feature we should insert relative to is not part of that body"); + throw Base::ValueError("Body: the feature we should insert relative to is not part of that body"); } //ensure that all origin links are ok diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index 6a58a3915f..9803f53975 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -106,7 +106,7 @@ const gp_Pnt Feature::getPointFromFace(const TopoDS_Face& f) // TODO: Other method, e.g. intersect X,Y,Z axis with the (unlimited?) face? // Or get a "corner" point if the face is limited? - throw Base::Exception("getPointFromFace(): Not implemented yet for this case"); + throw Base::NotImplementedError("getPointFromFace(): Not implemented yet for this case"); } Part::Feature* Feature::getBaseObject(bool silent) const { @@ -127,7 +127,7 @@ Part::Feature* Feature::getBaseObject(bool silent) const { // If the function not in silent mode throw the exception describing the error if (!silent && err) { - throw Base::Exception(err); + throw Base::RuntimeError(err); } return BaseObject; @@ -142,10 +142,10 @@ const TopoDS_Shape& Feature::getBaseShape() const { const TopoDS_Shape& result = BaseObject->Shape.getValue(); if (result.IsNull()) - throw Base::Exception("Base feature's shape is invalid"); + throw Base::ValueError("Base feature's shape is invalid"); TopExp_Explorer xp (result, TopAbs_SOLID); if (!xp.More()) - throw Base::Exception("Base feature's shape is not a solid"); + throw Base::ValueError("Base feature's shape is not a solid"); return result; } @@ -159,7 +159,7 @@ const Part::TopoShape Feature::getBaseTopoShape() const { const Part::TopoShape& result = BaseObject->Shape.getShape(); if (result.getShape().IsNull()) - throw Base::Exception("Base feature's TopoShape is invalid"); + throw Base::ValueError("Base feature's TopoShape is invalid"); return result; } @@ -183,7 +183,7 @@ gp_Pln Feature::makePlnFromPlane(const App::DocumentObject* obj) { const App::GeoFeature* plane = static_cast(obj); if (plane == NULL) - throw Base::Exception("Feature: Null object"); + throw Base::ValueError("Feature: Null object"); Base::Vector3d pos = plane->Placement.getValue().getPosition(); Base::Rotation rot = plane->Placement.getValue().getRotation(); @@ -196,7 +196,7 @@ TopoDS_Shape Feature::makeShapeFromPlane(const App::DocumentObject* obj) { BRepBuilderAPI_MakeFace builder(makePlnFromPlane(obj)); if (!builder.IsDone()) - throw Base::Exception("Feature: Could not create shape from base plane"); + throw Base::CADKernelError("Feature: Could not create shape from base plane"); return builder.Shape(); } diff --git a/src/Mod/PartDesign/App/FeatureDraft.cpp b/src/Mod/PartDesign/App/FeatureDraft.cpp index 1e3188e59e..67d6391b06 100644 --- a/src/Mod/PartDesign/App/FeatureDraft.cpp +++ b/src/Mod/PartDesign/App/FeatureDraft.cpp @@ -118,7 +118,7 @@ App::DocumentObjectExecReturn *Draft::execute(void) } else if (refDirection->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { std::vector subStrings = PullDirection.getSubValues(); if (subStrings.empty() || subStrings[0].empty()) - throw Base::Exception("No pull direction reference specified"); + throw Base::ValueError("No pull direction reference specified"); Part::Feature* refFeature = static_cast(refDirection); Part::TopoShape refShape = refFeature->Shape.getShape(); @@ -127,17 +127,17 @@ App::DocumentObjectExecReturn *Draft::execute(void) if (ref.ShapeType() == TopAbs_EDGE) { TopoDS_Edge refEdge = TopoDS::Edge(ref); if (refEdge.IsNull()) - throw Base::Exception("Failed to extract pull direction reference edge"); + throw Base::ValueError("Failed to extract pull direction reference edge"); BRepAdaptor_Curve adapt(refEdge); if (adapt.GetType() != GeomAbs_Line) - throw Base::Exception("Pull direction reference edge must be linear"); + throw Base::TypeError("Pull direction reference edge must be linear"); pullDirection = adapt.Line().Direction(); } else { - throw Base::Exception("Pull direction reference must be an edge or a datum line"); + throw Base::TypeError("Pull direction reference must be an edge or a datum line"); } } else { - throw Base::Exception("Pull direction reference must be an edge of a feature or a datum line"); + throw Base::TypeError("Pull direction reference must be an edge of a feature or a datum line"); } TopLoc_Location invObjLoc = this->getLocation().Inverted(); @@ -193,7 +193,7 @@ App::DocumentObjectExecReturn *Draft::execute(void) } if (!found) - throw Base::Exception("No neutral plane specified and none can be guessed"); + throw Base::RuntimeError("No neutral plane specified and none can be guessed"); } else { if (refPlane->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { PartDesign::Plane* plane = static_cast(refPlane); @@ -205,7 +205,7 @@ App::DocumentObjectExecReturn *Draft::execute(void) } else if (refPlane->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { std::vector subStrings = NeutralPlane.getSubValues(); if (subStrings.empty() || subStrings[0].empty()) - throw Base::Exception("No neutral plane reference specified"); + throw Base::ValueError("No neutral plane reference specified"); Part::Feature* refFeature = static_cast(refPlane); Part::TopoShape refShape = refFeature->Shape.getShape(); @@ -214,10 +214,10 @@ App::DocumentObjectExecReturn *Draft::execute(void) if (ref.ShapeType() == TopAbs_FACE) { TopoDS_Face refFace = TopoDS::Face(ref); if (refFace.IsNull()) - throw Base::Exception("Failed to extract neutral plane reference face"); + throw Base::ValueError("Failed to extract neutral plane reference face"); BRepAdaptor_Surface adapt(refFace); if (adapt.GetType() != GeomAbs_Plane) - throw Base::Exception("Neutral plane reference face must be planar"); + throw Base::TypeError("Neutral plane reference face must be planar"); neutralPlane = adapt.Plane(); } else if (ref.ShapeType() == TopAbs_EDGE) { @@ -225,22 +225,22 @@ App::DocumentObjectExecReturn *Draft::execute(void) // Create neutral plane through edge normal to pull direction TopoDS_Edge refEdge = TopoDS::Edge(ref); if (refEdge.IsNull()) - throw Base::Exception("Failed to extract neutral plane reference edge"); + throw Base::ValueError("Failed to extract neutral plane reference edge"); BRepAdaptor_Curve c(refEdge); if (c.GetType() != GeomAbs_Line) - throw Base::Exception("Neutral plane reference edge must be linear"); + throw Base::TypeError("Neutral plane reference edge must be linear"); double a = c.Line().Angle(gp_Lin(c.Value(c.FirstParameter()), pullDirection)); if (std::fabs(a - M_PI_2) > Precision::Confusion()) - throw Base::Exception("Neutral plane reference edge must be normal to pull direction"); + throw Base::ValueError("Neutral plane reference edge must be normal to pull direction"); neutralPlane = gp_Pln(c.Value(c.FirstParameter()), pullDirection); } else { - throw Base::Exception("Neutral plane reference can only be an edge if pull direction is defined"); + throw Base::TypeError("Neutral plane reference can only be an edge if pull direction is defined"); } } else { - throw Base::Exception("Neutral plane reference must be a face"); + throw Base::TypeError("Neutral plane reference must be a face"); } } else { - throw Base::Exception("Neutral plane reference must be face of a feature or a datum plane"); + throw Base::TypeError("Neutral plane reference must be face of a feature or a datum plane"); } TopLoc_Location invObjLoc = this->getLocation().Inverted(); diff --git a/src/Mod/PartDesign/App/FeatureDressUp.cpp b/src/Mod/PartDesign/App/FeatureDressUp.cpp index 04ddf6ec86..3b39144c36 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.cpp +++ b/src/Mod/PartDesign/App/FeatureDressUp.cpp @@ -84,7 +84,7 @@ Part::Feature *DressUp::getBaseObject(bool silent) const } if (!silent && err) { - throw Base::Exception(err); + throw Base::RuntimeError(err); } return rv; diff --git a/src/Mod/PartDesign/App/FeatureGroove.cpp b/src/Mod/PartDesign/App/FeatureGroove.cpp index 036d06e5f2..60e079ab78 100644 --- a/src/Mod/PartDesign/App/FeatureGroove.cpp +++ b/src/Mod/PartDesign/App/FeatureGroove.cpp @@ -150,7 +150,7 @@ App::DocumentObjectExecReturn *Groove::execute(void) BRepAlgoAPI_Cut mkCut(base, result); // Let's check if the fusion has been successful if (!mkCut.IsDone()) - throw Base::Exception("Cut out of base feature failed"); + throw Base::CADKernelError("Cut out of base feature failed"); // we have to get the solids (fuse sometimes creates compounds) TopoDS_Shape solRes = this->getSolid(mkCut.Shape()); diff --git a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp index 69117d2409..7403490642 100644 --- a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp +++ b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp @@ -71,21 +71,21 @@ const std::list LinearPattern::getTransformations(const std::vector subStrings = Direction.getSubValues(); if (subStrings.empty()) - throw Base::Exception("No direction reference specified"); + throw Base::ValueError("No direction reference specified"); gp_Dir dir; if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { @@ -107,10 +107,10 @@ const std::list LinearPattern::getTransformations(const std::vector LinearPattern::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { if (subStrings[0].empty()) - throw Base::Exception("No direction reference specified"); + throw Base::ValueError("No direction reference specified"); Part::Feature* refFeature = static_cast(refObject); Part::TopoShape refShape = refFeature->Shape.getShape(); TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str()); @@ -143,26 +143,26 @@ const std::list LinearPattern::getTransformations(const std::vectorgetLocation().Inverted(); dir.Transform(invObjLoc.Transformation()); diff --git a/src/Mod/PartDesign/App/FeatureMirrored.cpp b/src/Mod/PartDesign/App/FeatureMirrored.cpp index 17e4bdf07b..7189ff1a34 100644 --- a/src/Mod/PartDesign/App/FeatureMirrored.cpp +++ b/src/Mod/PartDesign/App/FeatureMirrored.cpp @@ -61,10 +61,10 @@ const std::list Mirrored::getTransformations(const std::vector subStrings = MirrorPlane.getSubValues(); if (subStrings.empty()) - throw Base::Exception("No mirror plane reference specified"); + throw Base::ValueError("No mirror plane reference specified"); gp_Pnt axbase; gp_Dir axdir; @@ -104,21 +104,21 @@ const std::list Mirrored::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { if (subStrings[0].empty()) - throw Base::Exception("No direction reference specified"); + throw Base::ValueError("No direction reference specified"); Part::TopoShape baseShape = static_cast(refObject)->Shape.getShape(); // TODO: Check for multiple mirror planes? TopoDS_Shape shape = baseShape.getSubShape(subStrings[0].c_str()); TopoDS_Face face = TopoDS::Face(shape); if (face.IsNull()) - throw Base::Exception("Failed to extract mirror plane"); + throw Base::ValueError("Failed to extract mirror plane"); BRepAdaptor_Surface adapt(face); if (adapt.GetType() != GeomAbs_Plane) - throw Base::Exception("Mirror face must be planar"); + throw Base::TypeError("Mirror face must be planar"); axbase = getPointFromFace(face); axdir = adapt.Plane().Axis().Direction(); } else { - throw Base::Exception("Mirror plane reference must be a sketch axis, a face of a feature or a datum plane"); + throw Base::ValueError("Mirror plane reference must be a sketch axis, a face of a feature or a datum plane"); } TopLoc_Location invObjLoc = this->getLocation().Inverted(); diff --git a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp index c80c91f400..dbcceaff66 100644 --- a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp +++ b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp @@ -56,7 +56,7 @@ void MultiTransform::positionBySupport(void) for (std::vector::const_iterator f = transFeatures.begin(); f != transFeatures.end(); ++f) { if (!((*f)->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()))) - throw Base::Exception("Transformation features must be subclasses of Transformed"); + throw Base::TypeError("Transformation features must be subclasses of Transformed"); PartDesign::Transformed* transFeature = static_cast(*f); transFeature->Placement.setValue(this->Placement.getValue()); @@ -102,7 +102,7 @@ const std::list MultiTransform::getTransformations(const std::vectorgetTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()))) - throw Base::Exception("Transformation features must be subclasses of Transformed"); + throw Base::TypeError("Transformation features must be subclasses of Transformed"); PartDesign::Transformed* transFeature = static_cast(*f); std::list newTransformations = transFeature->getTransformations(originals); @@ -131,9 +131,9 @@ const std::list MultiTransform::getTransformations(const std::vector::const_iterator ot = oldTransformations.begin(); diff --git a/src/Mod/PartDesign/App/FeaturePipe.cpp b/src/Mod/PartDesign/App/FeaturePipe.cpp index 8c07302849..d298b4c584 100644 --- a/src/Mod/PartDesign/App/FeaturePipe.cpp +++ b/src/Mod/PartDesign/App/FeaturePipe.cpp @@ -470,10 +470,10 @@ void Pipe::buildPipePath(const Part::TopoShape& shape, const std::vector< std::s TopoDS_Iterator it(shape.getShape()); for (; it.More(); it.Next()) { if (it.Value().IsNull()) - throw Base::Exception("In valid element in spine."); + throw Base::ValueError("In valid element in spine."); if ((it.Value().ShapeType() != TopAbs_EDGE) && (it.Value().ShapeType() != TopAbs_WIRE)) { - throw Base::Exception("Element in spine is neither an edge nor a wire."); + throw Base::TypeError("Element in spine is neither an edge nor a wire."); } } @@ -485,15 +485,15 @@ void Pipe::buildPipePath(const Part::TopoShape& shape, const std::vector< std::s ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, Precision::Confusion(), Standard_True, hWires); int len = hWires->Length(); if (len != 1) - throw Base::Exception("Spine is not connected."); + throw Base::ValueError("Spine is not connected."); path = hWires->Value(1); } else { - throw Base::Exception("Spine is neither an edge nor a wire."); + throw Base::TypeError("Spine is neither an edge nor a wire."); } } catch (Standard_Failure&) { - throw Base::Exception("Invalid spine."); + throw Base::CADKernelError("Invalid spine."); } } } diff --git a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp index fb623d9ebd..fc37f6a23f 100644 --- a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp +++ b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp @@ -69,10 +69,10 @@ const std::list PolarPattern::getTransformations(const std::vector PolarPattern::getTransformations(const std::vector subStrings = Axis.getSubValues(); if (subStrings.empty()) - throw Base::Exception("No axis reference specified"); + throw Base::ValueError("No axis reference specified"); gp_Pnt axbase; gp_Dir axdir; @@ -121,7 +121,7 @@ const std::list PolarPattern::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { if (subStrings[0].empty()) - throw Base::Exception("No axis reference specified"); + throw Base::ValueError("No axis reference specified"); Part::Feature* refFeature = static_cast(refObject); Part::TopoShape refShape = refFeature->Shape.getShape(); TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str()); @@ -129,18 +129,18 @@ const std::list PolarPattern::getTransformations(const std::vectorgetLocation().Inverted(); axbase.Transform(invObjLoc.Transformation()); diff --git a/src/Mod/PartDesign/App/FeatureRevolution.cpp b/src/Mod/PartDesign/App/FeatureRevolution.cpp index fca80d6191..f547f77fd8 100644 --- a/src/Mod/PartDesign/App/FeatureRevolution.cpp +++ b/src/Mod/PartDesign/App/FeatureRevolution.cpp @@ -42,6 +42,7 @@ #include #include +#include #include "FeatureRevolution.h" @@ -157,7 +158,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void) BRepAlgoAPI_Fuse mkFuse(base, result); // Let's check if the fusion has been successful if (!mkFuse.IsDone()) - throw Base::Exception("Fusion with base feature failed"); + throw Part::BooleanException("Fusion with base feature failed"); result = mkFuse.Shape(); result = refineShapeIfActive(result); } diff --git a/src/Mod/PartDesign/App/FeatureScaled.cpp b/src/Mod/PartDesign/App/FeatureScaled.cpp index 69abc88892..95e06e1d03 100644 --- a/src/Mod/PartDesign/App/FeatureScaled.cpp +++ b/src/Mod/PartDesign/App/FeatureScaled.cpp @@ -60,10 +60,10 @@ const std::list Scaled::getTransformations(const std::vector(result); @@ -166,7 +166,7 @@ Part::Feature* ProfileBased::getVerifiedObject(bool silent) const { } if (!silent && err) { - throw Base::Exception (err); + throw Base::RuntimeError (err); } return static_cast(result); @@ -214,7 +214,7 @@ TopoDS_Shape ProfileBased::getVerifiedFace(bool silent) const { } if (!silent && err) { - throw Base::Exception (err); + throw Base::RuntimeError (err); } return TopoDS_Face(); @@ -225,20 +225,20 @@ std::vector ProfileBased::getProfileWires() const { std::vector result; if(!Profile.getValue() || !Profile.getValue()->isDerivedFrom(Part::Feature::getClassTypeId())) - throw Base::Exception("No valid profile linked"); + throw Base::TypeError("No valid profile linked"); TopoDS_Shape shape; if(Profile.getValue()->isDerivedFrom(Part::Part2DObject::getClassTypeId())) shape = Profile.getValue()->Shape.getValue(); else { if(Profile.getSubValues().empty()) - throw Base::Exception("No valid subelement linked in Part::Feature"); + throw Base::ValueError("No valid subelement linked in Part::Feature"); shape = Profile.getValue()->Shape.getShape().getSubShape(Profile.getSubValues().front().c_str()); } if (shape.IsNull()) - throw Base::Exception("Linked shape object is empty"); + throw Base::ValueError("Linked shape object is empty"); // this is a workaround for an obscure OCC bug which leads to empty tessellations // for some faces. Making an explicit copy of the linked shape seems to fix it. @@ -247,14 +247,14 @@ std::vector ProfileBased::getProfileWires() const { BRepBuilderAPI_Copy copy(shape); shape = copy.Shape(); if (shape.IsNull()) - throw Base::Exception("Linked shape object is empty"); + throw Base::ValueError("Linked shape object is empty"); TopExp_Explorer ex; for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) { result.push_back(TopoDS::Wire(ex.Current())); } if (result.empty()) // there can be several wires - throw Base::Exception("Linked shape object is not a wire"); + throw Base::ValueError("Linked shape object is not a wire"); return result; } @@ -281,19 +281,19 @@ const TopoDS_Face ProfileBased::getSupportFace() const { // get the selected sub shape (a Face) const Part::TopoShape &shape = part->Shape.getShape(); if (shape.getShape().IsNull()) - throw Base::Exception("Sketch support shape is empty!"); + throw Base::ValueError("Sketch support shape is empty!"); TopoDS_Shape sh = shape.getSubShape(sub[0].c_str()); if (sh.IsNull()) - throw Base::Exception("Null shape in SketchBased::getSupportFace()!"); + throw Base::ValueError("Null shape in SketchBased::getSupportFace()!"); const TopoDS_Face face = TopoDS::Face(sh); if (face.IsNull()) - throw Base::Exception("Null face in SketchBased::getSupportFace()!"); + throw Base::ValueError("Null face in SketchBased::getSupportFace()!"); BRepAdaptor_Surface adapt(face); if (adapt.GetType() != GeomAbs_Plane) - throw Base::Exception("No planar face in SketchBased::getSupportFace()!"); + throw Base::TypeError("No planar face in SketchBased::getSupportFace()!"); return face; } @@ -343,7 +343,7 @@ Part::Feature *ProfileBased::getBaseObject(bool silent) const } if (!silent && err) { - throw Base::Exception (err); + throw Base::RuntimeError (err); } return rv; @@ -367,7 +367,7 @@ void ProfileBased::getUpToFaceFromLinkSub(TopoDS_Face& upToFace, std::vector subStrings = refFace.getSubValues(); if (ref == NULL) - throw Base::Exception("SketchBased: Up to face: No face selected"); + throw Base::ValueError("SketchBased: Up to face: No face selected"); if (ref->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { upToFace = TopoDS::Face(makeShapeFromPlane(ref)); @@ -379,16 +379,16 @@ void ProfileBased::getUpToFaceFromLinkSub(TopoDS_Face& upToFace, } if (!ref->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) - throw Base::Exception("SketchBased: Up to face: Must be face of a feature"); + throw Base::TypeError("SketchBased: Up to face: Must be face of a feature"); Part::TopoShape baseShape = static_cast(ref)->Shape.getShape(); if (subStrings.empty() || subStrings[0].empty()) - throw Base::Exception("SketchBased: Up to face: No face selected"); + throw Base::ValueError("SketchBased: Up to face: No face selected"); // TODO: Check for multiple UpToFaces? upToFace = TopoDS::Face(baseShape.getSubShape(subStrings[0].c_str())); if (upToFace.IsNull()) - throw Base::Exception("SketchBased: Up to face: Failed to extract face"); + throw Base::ValueError("SketchBased: Up to face: Failed to extract face"); } void ProfileBased::getUpToFace(TopoDS_Face& upToFace, @@ -402,11 +402,11 @@ void ProfileBased::getUpToFace(TopoDS_Face& upToFace, if ((method == "UpToLast") || (method == "UpToFirst")) { // Check for valid support object if (support.IsNull()) - throw Base::Exception("SketchBased: Up to face: No support in Sketch and no base feature!"); + throw Base::ValueError("SketchBased: Up to face: No support in Sketch and no base feature!"); std::vector cfaces = Part::findAllFacesCutBy(support, sketchshape, dir); if (cfaces.empty()) - throw Base::Exception("SketchBased: Up to face: No faces found in this direction"); + throw Base::ValueError("SketchBased: Up to face: No faces found in this direction"); // Find nearest/furthest face std::vector::const_iterator it, it_near, it_far; @@ -464,7 +464,7 @@ void ProfileBased::getUpToFace(TopoDS_Face& upToFace, #endif ); if (!mkFace.IsDone()) - throw Base::Exception("SketchBased: Up To Face: Failed to create unlimited face"); + throw Base::ValueError("SketchBased: Up To Face: Failed to create unlimited face"); upToFace = TopoDS::Face(mkFace.Shape()); upToFace.Location(loc); } @@ -477,13 +477,13 @@ void ProfileBased::getUpToFace(TopoDS_Face& upToFace, if (adapt2.GetType() == GeomAbs_Plane) { if (adapt1.Plane().Axis().IsNormal(adapt2.Plane().Axis(), Precision::Confusion())) - throw Base::Exception("SketchBased: Up to face: Must not be parallel to extrusion direction!"); + throw Base::ValueError("SketchBased: Up to face: Must not be parallel to extrusion direction!"); } // We must measure from sketchshape, not supportface, here BRepExtrema_DistShapeShape distSS(sketchshape, upToFace); if (distSS.Value() < Precision::Confusion()) - throw Base::Exception("SketchBased: Up to face: Must not intersect sketch!"); + throw Base::ValueError("SketchBased: Up to face: Must not intersect sketch!"); // Move the face in the extrusion direction // TODO: For non-planar faces, we could consider offsetting the surface @@ -494,7 +494,7 @@ void ProfileBased::getUpToFace(TopoDS_Face& upToFace, TopLoc_Location loc(mov); upToFace.Move(loc); } else { - throw Base::Exception("SketchBased: Up to Face: Offset not supported yet for non-planar faces"); + throw Base::TypeError("SketchBased: Up to Face: Offset not supported yet for non-planar faces"); } } } @@ -537,10 +537,10 @@ void ProfileBased::generatePrism(TopoDS_Shape& prism, // resulting shape creates problems with Pocket BRepPrimAPI_MakePrism PrismMaker(from, Ltotal*gp_Vec(dir), 0,1); // finite prism if (!PrismMaker.IsDone()) - throw Base::Exception("SketchBased: Length: Could not extrude the sketch!"); + throw Base::RuntimeError("SketchBased: Length: Could not extrude the sketch!"); prism = PrismMaker.Shape(); } else { - throw Base::Exception("SketchBased: Internal error: Unknown method for generatePrism()"); + throw Base::RuntimeError("SketchBased: Internal error: Unknown method for generatePrism()"); } } @@ -655,7 +655,7 @@ bool ProfileBased::checkLineCrossesFace(const gp_Lin &line, const TopoDS_Face &f TopoDS_Wire outerWire = ShapeAnalysis::OuterWire(face); BRepBuilderAPI_MakeEdge mkEdge(line); if (!mkEdge.IsDone()) - throw Base::Exception("Revolve: Unexpected OCE failure"); + throw Base::RuntimeError("Revolve: Unexpected OCE failure"); BRepAdaptor_Curve axis(TopoDS::Edge(mkEdge.Shape())); TopExp_Explorer ex; @@ -990,7 +990,7 @@ void ProfileBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std // Check that axis is perpendicular with sketch plane! if (sketchplane.Axis().Direction().IsParallel(gp_Dir(dir.x, dir.y, dir.z), Precision::Angular())) - throw Base::Exception("Rotation axis must not be perpendicular with the sketch plane"); + throw Base::ValueError("Rotation axis must not be perpendicular with the sketch plane"); return; } @@ -1001,13 +1001,13 @@ void ProfileBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std // Check that axis is perpendicular with sketch plane! if (sketchplane.Axis().Direction().IsParallel(gp_Dir(dir.x, dir.y, dir.z), Precision::Angular())) - throw Base::Exception("Rotation axis must not be perpendicular with the sketch plane"); + throw Base::ValueError("Rotation axis must not be perpendicular with the sketch plane"); return; } if (pcReferenceAxis->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { if (subReferenceAxis.empty()) - throw Base::Exception("No rotation axis reference specified"); + throw Base::ValueError("No rotation axis reference specified"); const Part::Feature* refFeature = static_cast(pcReferenceAxis); Part::TopoShape refShape = refFeature->Shape.getShape(); TopoDS_Shape ref = refShape.getSubShape(subReferenceAxis[0].c_str()); @@ -1015,10 +1015,10 @@ void ProfileBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std if (ref.ShapeType() == TopAbs_EDGE) { TopoDS_Edge refEdge = TopoDS::Edge(ref); if (refEdge.IsNull()) - throw Base::Exception("Failed to extract rotation edge"); + throw Base::ValueError("Failed to extract rotation edge"); BRepAdaptor_Curve adapt(refEdge); if (adapt.GetType() != GeomAbs_Line) - throw Base::Exception("Rotation edge must be a straight line"); + throw Base::TypeError("Rotation edge must be a straight line"); gp_Pnt b = adapt.Line().Location(); base = Base::Vector3d(b.X(), b.Y(), b.Z()); @@ -1027,14 +1027,14 @@ void ProfileBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std // Check that axis is co-planar with sketch plane! // Check that axis is perpendicular with sketch plane! if (sketchplane.Axis().Direction().IsParallel(d, Precision::Angular())) - throw Base::Exception("Rotation axis must not be perpendicular with the sketch plane"); + throw Base::ValueError("Rotation axis must not be perpendicular with the sketch plane"); return; } else { - throw Base::Exception("Rotation reference must be an edge"); + throw Base::TypeError("Rotation reference must be an edge"); } } - throw Base::Exception("Rotation axis reference is invalid"); + throw Base::TypeError("Rotation axis reference is invalid"); } Base::Vector3d ProfileBased::getProfileNormal() const { diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index 1bbb18a1ea..b9f71f2419 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -102,7 +102,7 @@ Part::Feature* Transformed::getBaseObject(bool silent) const { } if (!silent && err) { - throw Base::Exception(err); + throw Base::RuntimeError(err); } return rv; diff --git a/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp b/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp index 8be9d83070..5080340dd6 100644 --- a/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp @@ -102,7 +102,7 @@ bool TaskDlgFeatureParameters::accept() { // Make sure the feature is what we are expecting // Should be fine but you never know... if ( !feature->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) ) { - throw Base::Exception("Bad object processed in the feature dialog."); + throw Base::TypeError("Bad object processed in the feature dialog."); } App::DocumentObject* previous = static_cast(feature)->getBaseObject(/* silent = */ true ); @@ -115,7 +115,7 @@ bool TaskDlgFeatureParameters::accept() { Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); if (!feature->isValid()) { - throw Base::Exception(vp->getObject()->getStatusString()); + throw Base::RuntimeError(vp->getObject()->getStatusString()); } // detach the task panel from the selection to avoid to invoke diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index 7eb38b004a..801603e84f 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -871,7 +871,7 @@ bool TaskDlgPipeParameters::accept() try { Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); if (!vp->getObject()->isValid()) - throw Base::Exception(vp->getObject()->getStatusString()); + throw Base::RuntimeError(vp->getObject()->getStatusString()); Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); Gui::Command::commitCommand(); diff --git a/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp b/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp index f734f26ffc..3a75e00533 100644 --- a/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp @@ -323,7 +323,7 @@ bool TaskDlgShapeBinder::accept() try { Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); if (!vp->getObject()->isValid()) - throw Base::Exception(vp->getObject()->getStatusString()); + throw Base::RuntimeError(vp->getObject()->getStatusString()); Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); Gui::Command::commitCommand(); } diff --git a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp index 228226ced8..02ec7fb0e9 100644 --- a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp @@ -236,7 +236,7 @@ bool TaskDlgSketchBasedParameters::accept() { // Make sure the feature is what we are expecting // Should be fine but you never know... if ( !feature->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId()) ) { - throw Base::Exception("Bad object processed in the sketch based dialog."); + throw Base::TypeError("Bad object processed in the sketch based dialog."); } App::DocumentObject* sketch = static_cast(feature)->Profile.getValue(); diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp index 16b408f8fe..29d9bca1e0 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp @@ -448,9 +448,9 @@ void ComboLinks::clear() App::PropertyLinkSub &ComboLinks::getLink(int index) const { if (index < 0 || index > (ssize_t) linksInList.size()-1) - throw Base::Exception("ComboLinks::getLink:Index out of range"); + throw Base::IndexError("ComboLinks::getLink:Index out of range"); if (linksInList[index]->getValue() && doc && !(doc->isIn(linksInList[index]->getValue()))) - throw Base::Exception("Linked object is not in the document; it may have been deleted"); + throw Base::ValueError("Linked object is not in the document; it may have been deleted"); return *(linksInList[index]); } diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index 3b0be30a03..8072ecccb7 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -201,7 +201,7 @@ void fixSketchSupport (Sketcher::SketchObject* sketch) const App::Document* doc = sketch->getDocument(); PartDesign::Body *body = getBodyFor(sketch, /*messageIfNot*/ 0); if (!body) { - throw Base::Exception ("Couldn't find body for the sketch"); + throw Base::RuntimeError ("Couldn't find body for the sketch"); } // Get the Origin for the body @@ -226,7 +226,7 @@ void fixSketchSupport (Sketcher::SketchObject* sketch) else if (sketchVector == Base::Vector3d(1,0,0)) plane = origin->getYZ (); else { - throw Base::Exception("Sketch plane cannot be migrated"); + throw Base::ValueError("Sketch plane cannot be migrated"); } assert (plane); @@ -324,7 +324,7 @@ void relinkToBody (PartDesign::Feature *feature) { PartDesign::Body *body = PartDesign::Body::findBodyOf ( feature ); if (!body) { - throw Base::Exception ("Couldn't find body for the feature"); + throw Base::RuntimeError ("Couldn't find body for the feature"); } std::string bodyName = body->getNameInDocument (); diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index 3db8b1a923..bf80d4d4f9 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -133,7 +133,7 @@ bool ViewProvider::setEdit(int ModNum) if (!featureDlg) { featureDlg = this->getEditDialog(); if (!featureDlg) { // Shouldn't generally happen - throw Base::Exception ("Failed to create new edit dialog."); + throw Base::RuntimeError ("Failed to create new edit dialog."); } } @@ -146,7 +146,7 @@ bool ViewProvider::setEdit(int ModNum) TaskDlgFeatureParameters *ViewProvider::getEditDialog() { - throw Base::Exception("getEditDialog() not implemented"); + throw Base::NotImplementedError("getEditDialog() not implemented"); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index b3a2647989..54923f62d4 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -335,7 +335,7 @@ void ViewProviderBody::updateOriginDatumSize () { Gui::ViewProvider *vp = Gui::Application::Instance->getViewProvider(origin); if (!vp) { - throw Base::Exception ("No view provider linked to the Origin"); + throw Base::ValueError ("No view provider linked to the Origin"); } assert ( vp->isDerivedFrom ( Gui::ViewProviderOrigin::getClassTypeId () ) ); vpOrigin = static_cast ( vp ); diff --git a/src/Mod/PartDesign/Gui/WorkflowManager.cpp b/src/Mod/PartDesign/Gui/WorkflowManager.cpp index 12e1d918b9..e1e801f9c2 100644 --- a/src/Mod/PartDesign/Gui/WorkflowManager.cpp +++ b/src/Mod/PartDesign/Gui/WorkflowManager.cpp @@ -76,7 +76,7 @@ void WorkflowManager::init() { if (!_instance) { _instance = new WorkflowManager(); } else { - //throw Base::Exception( "Trying to init the workflow manager second time." ); + //throw Base::RuntimeError( "Trying to init the workflow manager second time." ); } }