Replace Base::Exception with appropriate subclass
This commit is contained in:
@@ -118,7 +118,7 @@ App::DocumentObjectExecReturn *Draft::execute(void)
|
||||
} else if (refDirection->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
std::vector<std::string> 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<Part::Feature*>(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<PartDesign::Plane*>(refPlane);
|
||||
@@ -205,7 +205,7 @@ App::DocumentObjectExecReturn *Draft::execute(void)
|
||||
} else if (refPlane->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
std::vector<std::string> 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<Part::Feature*>(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();
|
||||
|
||||
Reference in New Issue
Block a user