diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp
index 1ed848bdcc..a443dad8e0 100644
--- a/src/Mod/Part/App/AppPart.cpp
+++ b/src/Mod/Part/App/AppPart.cpp
@@ -23,6 +23,7 @@
#include
#include
#include
+#include
#include
@@ -246,6 +247,11 @@ PyMOD_INIT_FUNC(Part)
Py::Object module(partModule);
module.setAttr("OCC_VERSION", Py::String(OCC_VERSION_STRING_EXT));
+ // C++ exceptions
+ new Base::ExceptionProducer;
+ new Base::ExceptionProducer;
+ new Base::ExceptionProducer;
+
// Python exceptions
//
PyObject* OCCError = 0;
diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp
index 624020faec..9b2ab078ee 100644
--- a/src/Mod/Part/App/AppPartPy.cpp
+++ b/src/Mod/Part/App/AppPartPy.cpp
@@ -710,7 +710,7 @@ private:
} else if (PyObject_TypeCheck(pcPyShapeOrList, &(Part::TopoShapePy::Type))) {
const TopoDS_Shape& sh = static_cast(pcPyShapeOrList)->getTopoShapePtr()->getShape();
if (sh.IsNull())
- throw Base::Exception("Shape is null!");
+ throw NullShapeException("Shape is null!");
if (sh.ShapeType() == TopAbs_COMPOUND)
fm->useCompound(TopoDS::Compound(sh));
else
diff --git a/src/Mod/Part/App/AttachExtension.cpp b/src/Mod/Part/App/AttachExtension.cpp
index dfe18cfecc..bb7a87163e 100644
--- a/src/Mod/Part/App/AttachExtension.cpp
+++ b/src/Mod/Part/App/AttachExtension.cpp
@@ -37,7 +37,7 @@
using namespace Part;
using namespace Attacher;
-EXTENSION_PROPERTY_SOURCE(Part::AttachExtension, App::DocumentObjectExtension);
+EXTENSION_PROPERTY_SOURCE(Part::AttachExtension, App::DocumentObjectExtension)
AttachExtension::AttachExtension()
: _attacher(0)
@@ -113,7 +113,7 @@ bool AttachExtension::changeAttacherType(const char* typeName)
} else {
std::stringstream errMsg;
errMsg << "Object if this type is not derived from AttachEngine: " << typeName;
- throw Base::Exception(errMsg.str());
+ throw AttachEngineException(errMsg.str());
}
assert(false);//exec shouldn't ever get here
return false;
@@ -277,6 +277,28 @@ PyObject* AttachExtension::getExtensionPyObject(void) {
return Py::new_reference_to(ExtensionPythonObject);
}
+// ------------------------------------------------
+
+AttachEngineException::AttachEngineException()
+ : Base::Exception()
+{
+}
+
+AttachEngineException::AttachEngineException(const char * sMessage)
+ : Base::Exception(sMessage)
+{
+}
+
+AttachEngineException::AttachEngineException(const std::string& sMessage)
+ : Base::Exception(sMessage)
+{
+}
+
+AttachEngineException::AttachEngineException(const AttachEngineException &inst)
+ : Base::Exception(inst)
+{
+}
+
namespace App {
/// @cond DOXERR
diff --git a/src/Mod/Part/App/AttachExtension.h b/src/Mod/Part/App/AttachExtension.h
index b3cfe70923..23cee0093f 100644
--- a/src/Mod/Part/App/AttachExtension.h
+++ b/src/Mod/Part/App/AttachExtension.h
@@ -46,6 +46,19 @@
namespace Part
{
+class PartExport AttachEngineException : public Base::Exception
+{
+public:
+ /// Construction
+ AttachEngineException();
+ AttachEngineException(const char * sMessage);
+ AttachEngineException(const std::string& sMessage);
+ /// Construction
+ AttachEngineException(const AttachEngineException &inst);
+ /// Destruction
+ virtual ~AttachEngineException() throw() {}
+};
+
/**
* @brief The AttachableObject class is the thing to extend an object with
* that should be attachable. It includes the required properties, and
@@ -75,7 +88,7 @@ public:
*/
bool changeAttacherType(const char* typeName);
- Attacher::AttachEngine &attacher(void) const {if(!_attacher) throw Base::Exception("AttachableObject: no attacher is set."); return *_attacher;}
+ Attacher::AttachEngine &attacher(void) const {if(!_attacher) throw AttachEngineException("AttachableObject: no attacher is set."); return *_attacher;}
App::PropertyString AttacherType;
@@ -98,7 +111,7 @@ public:
virtual bool positionBySupport(void);
virtual bool isTouched_Mapping()
- {return true; /*support.isTouched isn't true when linked objects are changed... why?..*/};
+ {return true; /*support.isTouched isn't true when linked objects are changed... why?..*/}
virtual short int extensionMustExecute(void);
virtual App::DocumentObjectExecReturn *extensionExecute(void);
diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp
index 9974c90363..4aaef99efd 100644
--- a/src/Mod/Part/App/Attacher.cpp
+++ b/src/Mod/Part/App/Attacher.cpp
@@ -60,6 +60,7 @@
#include
#include "Attacher.h"
+#include "AttachExtension.h"
#include
#include
#include
@@ -165,7 +166,7 @@ const char* AttachEngine::eRefTypeStrings[]= {
-TYPESYSTEM_SOURCE_ABSTRACT(Attacher::AttachEngine, Base::BaseClass);
+TYPESYSTEM_SOURCE_ABSTRACT(Attacher::AttachEngine, Base::BaseClass)
AttachEngine::AttachEngine()
: mapMode(mmDeactivated), mapReverse(false), attachParameter(0.0),
@@ -247,7 +248,7 @@ Base::Placement AttachEngine::placementFactory(const gp_Dir &ZAxis,
//find out, to which axis of support Normal is closest to.
//The result will be written into pos variable (0..2 = X..Z)
if (!placeOfRef)
- throw Base::Exception("AttachEngine::placementFactory: for Legacy mode, placement of the reference must be supplied. Got null instead!");
+ throw AttachEngineException("AttachEngine::placementFactory: for Legacy mode, placement of the reference must be supplied. Got null instead!");
Base::Placement &Place = *placeOfRef;
Base::Vector3d dX,dY,dZ;//internal axes of support object, as they are in global space
Place.getRotation().multVec(Base::Vector3d(1,0,0),dX);
@@ -329,7 +330,7 @@ void AttachEngine::suggestMapModes(SuggestResult &result) const
} catch (Base::Exception &err) {
result.references_Types = typeStr;
result.message = SuggestResult::srLinkBroken;
- result.error = err;
+ result.error.Exception::operator = (err);
return;
}
@@ -502,7 +503,7 @@ eRefType AttachEngine::getShapeType(const TopoDS_Shape& sh)
case TopAbs_VERTEX:
return rtVertex;
default:
- throw Base::Exception("AttachEngine::getShapeType: unexpected TopoDS_Shape::ShapeType");
+ throw AttachEngineException("AttachEngine::getShapeType: unexpected TopoDS_Shape::ShapeType");
}//switch shapetype
return rtAnything;//shouldn't happen, it's here to shut up compiler warning
}
@@ -560,7 +561,7 @@ eRefType AttachEngine::downgradeType(eRefType type)
case rtPart:
return rtAnything;
default:
- throw Base::Exception("AttachEngine::downgradeType: unknown type");
+ throw AttachEngineException("AttachEngine::downgradeType: unknown type");
}
}
@@ -621,7 +622,7 @@ int AttachEngine::isShapeOfType(eRefType shapeType, eRefType requirement)
std::string AttachEngine::getModeName(eMapMode mmode)
{
if(mmode < 0 || mmode >= mmDummy_NumberOfModes)
- throw Base::Exception("AttachEngine::getModeName: Attachment Mode index is out of range");
+ throw AttachEngineException("AttachEngine::getModeName: Attachment Mode index is out of range");
return std::string(AttachEngine::eMapModeStrings[mmode]);
}
@@ -634,14 +635,14 @@ eMapMode AttachEngine::getModeByName(const std::string &modeName)
}
std::stringstream errMsg;
errMsg << "AttachEngine::getModeByName: mode with this name doesn't exist: " << modeName;
- throw Base::Exception(errMsg.str());
+ throw AttachEngineException(errMsg.str());
}
std::string AttachEngine::getRefTypeName(eRefType shapeType)
{
eRefType flagless = eRefType(shapeType & 0xFF);
if(flagless < 0 || flagless >= rtDummy_numberOfShapeTypes)
- throw Base::Exception("eRefType value is out of range");
+ throw AttachEngineException("eRefType value is out of range");
std::string result = std::string(eRefTypeStrings[flagless]);
if (shapeType & rtFlagHasPlacement){
result.append("|Placement");
@@ -667,13 +668,13 @@ eRefType AttachEngine::getRefTypeByName(const std::string& typeName)
} else {
std::stringstream errmsg;
errmsg << "RefType flag not recognized: " << flags;
- throw Base::Exception(errmsg.str());
+ throw AttachEngineException(errmsg.str());
}
}
}
std::stringstream errmsg;
errmsg << "RefType not recognized: " << typeName;
- throw Base::Exception(errmsg.str());
+ throw AttachEngineException(errmsg.str());
}
GProp_GProps AttachEngine::getInertialPropsOfShape(const std::vector &shapes)
@@ -685,7 +686,7 @@ GProp_GProps AttachEngine::getInertialPropsOfShape(const std::vectorgetTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) {
- throw Base::Exception("AttachEngine3D: link points to something that is not App::GeoFeature");
+ throw AttachEngineException("AttachEngine3D: link points to something that is not App::GeoFeature");
}
App::GeoFeature* geof = static_cast(objs[i]);
geofs[i] = geof;
@@ -778,16 +779,16 @@ void AttachEngine::readLinks(const App::PropertyLinkSubList &references,
if (geof->isDerivedFrom(Part::Feature::getClassTypeId())){
shape = &(static_cast(geof)->Shape.getShape());
if (shape->isNull()){
- throw Base::Exception("AttachEngine3D: Part has null shape");
+ throw AttachEngineException("AttachEngine3D: Part has null shape");
}
if (sub[i].length()>0){
try{
storage.push_back(shape->getSubShape(sub[i].c_str()));
} catch (Standard_Failure&){
- throw Base::Exception("AttachEngine3D: subshape not found");
+ throw AttachEngineException("AttachEngine3D: subshape not found");
}
if(storage[storage.size()-1].IsNull())
- throw Base::Exception("AttachEngine3D: null subshape");
+ throw AttachEngineException("AttachEngine3D: null subshape");
shapes[i] = &(storage[storage.size()-1]);
} else {
shapes[i] = &(shape->getShape());
@@ -857,7 +858,7 @@ void AttachEngine::verifyReferencesAreSafe(const App::PropertyLinkSubList &refer
}
}
if (!found){
- throw Base::Exception("AttachEngine: verifyReferencesAreSafe: references point to deleted object.");
+ throw AttachEngineException("AttachEngine: verifyReferencesAreSafe: references point to deleted object.");
}
}
}
@@ -865,7 +866,7 @@ void AttachEngine::verifyReferencesAreSafe(const App::PropertyLinkSubList &refer
//=================================================================================
-TYPESYSTEM_SOURCE(Attacher::AttachEngine3D, Attacher::AttachEngine);
+TYPESYSTEM_SOURCE(Attacher::AttachEngine3D, Attacher::AttachEngine)
AttachEngine3D::AttachEngine3D()
{
@@ -1586,12 +1587,12 @@ double AttachEngine3D::calculateFoldAngle(gp_Vec axA, gp_Vec axB, gp_Vec edA, gp
edB.Normalize();
gp_Vec norm = axA.Crossed(axB);
if (norm.Magnitude() < Precision::Confusion())
- throw Base::Exception("calculateFoldAngle: Folding axes are parallel, folding angle cannot be computed.");
+ throw AttachEngineException("calculateFoldAngle: Folding axes are parallel, folding angle cannot be computed.");
norm.Normalize();
double a = edA.Dot(axA);
double ra = edA.Crossed(axA).Magnitude();
if (fabs(ra) < Precision::Confusion())
- throw Base::Exception("calculateFoldAngle: axisA and edgeA are parallel, folding can't be computed.");
+ throw AttachEngineException("calculateFoldAngle: axisA and edgeA are parallel, folding can't be computed.");
double b = edB.Dot(axB);
double costheta = axB.Dot(axA);
double sintheta = axA.Crossed(axB).Dot(norm);
@@ -1602,7 +1603,7 @@ double AttachEngine3D::calculateFoldAngle(gp_Vec axA, gp_Vec axB, gp_Vec edA, gp
double xa = k + l*singama/cosgama;
double cos_unfold = -xa/ra;
if (fabs(cos_unfold)>0.999)
- throw Base::Exception("calculateFoldAngle: cosine of folding angle is too close to or above 1.");
+ throw AttachEngineException("calculateFoldAngle: cosine of folding angle is too close to or above 1.");
return acos(cos_unfold);
}
diff --git a/src/Mod/Part/App/Attacher.h b/src/Mod/Part/App/Attacher.h
index 9e969de413..114a067e8b 100644
--- a/src/Mod/Part/App/Attacher.h
+++ b/src/Mod/Part/App/Attacher.h
@@ -203,7 +203,7 @@ struct SuggestResult{
*/
refTypeString references_Types;
- Base::Exception error;
+ Base::RuntimeError error;
};
diff --git a/src/Mod/Part/App/FaceMaker.cpp b/src/Mod/Part/App/FaceMaker.cpp
index a42e6fb0c4..60a7579656 100644
--- a/src/Mod/Part/App/FaceMaker.cpp
+++ b/src/Mod/Part/App/FaceMaker.cpp
@@ -32,13 +32,13 @@
#include "FaceMaker.h"
-#include
+#include "TopoShape.h"
#include
#include
-TYPESYSTEM_SOURCE_ABSTRACT(Part::FaceMaker, Base::BaseClass);
-TYPESYSTEM_SOURCE_ABSTRACT(Part::FaceMakerPublic, Part::FaceMaker);
+TYPESYSTEM_SOURCE_ABSTRACT(Part::FaceMaker, Base::BaseClass)
+TYPESYSTEM_SOURCE_ABSTRACT(Part::FaceMakerPublic, Part::FaceMaker)
void Part::FaceMaker::addWire(const TopoDS_Wire& w)
{
@@ -78,7 +78,7 @@ const TopoDS_Face& Part::FaceMaker::Face()
{
const TopoDS_Shape &sh = this->Shape();
if(sh.IsNull())
- throw Base::Exception("Part::FaceMaker: result shape is null.");
+ throw NullShapeException("Part::FaceMaker: result shape is null.");
if (sh.ShapeType() != TopAbs_FACE)
throw Base::TypeError("Part::FaceMaker: return shape is not a single face.");
return TopoDS::Face(sh);
@@ -164,7 +164,7 @@ void Part::FaceMaker::throwNotImplemented()
//----------------------------------------------------------------------------------------
-TYPESYSTEM_SOURCE(Part::FaceMakerSimple, Part::FaceMakerPublic);
+TYPESYSTEM_SOURCE(Part::FaceMakerSimple, Part::FaceMakerPublic)
std::string Part::FaceMakerSimple::getUserFriendlyName() const
diff --git a/src/Mod/Part/App/FaceMakerBullseye.cpp b/src/Mod/Part/App/FaceMakerBullseye.cpp
index 9bb5e45473..69404fcf43 100644
--- a/src/Mod/Part/App/FaceMakerBullseye.cpp
+++ b/src/Mod/Part/App/FaceMakerBullseye.cpp
@@ -50,13 +50,13 @@
#include "FaceMakerBullseye.h"
#include "FaceMakerCheese.h"
-#include
+#include "TopoShape.h"
#include
using namespace Part;
-TYPESYSTEM_SOURCE(Part::FaceMakerBullseye, Part::FaceMakerPublic);
+TYPESYSTEM_SOURCE(Part::FaceMakerBullseye, Part::FaceMakerPublic)
void FaceMakerBullseye::setPlane(const gp_Pln &plane)
{
@@ -166,7 +166,7 @@ bool FaceMakerBullseye::FaceDriller::hitTest(gp_Pnt point) const
TopAbs_State ret = cl.State();
switch(ret){
case TopAbs_UNKNOWN:
- throw Base::Exception("FaceMakerBullseye::FaceDriller::hitTest: result unknown.");
+ throw Base::ValueError("FaceMakerBullseye::FaceDriller::hitTest: result unknown.");
break;
default:
return ret == TopAbs_IN || ret == TopAbs_ON;
diff --git a/src/Mod/Part/App/FeatureExtrusion.cpp b/src/Mod/Part/App/FeatureExtrusion.cpp
index c7fb569645..17c0ce942f 100644
--- a/src/Mod/Part/App/FeatureExtrusion.cpp
+++ b/src/Mod/Part/App/FeatureExtrusion.cpp
@@ -149,8 +149,8 @@ Extrusion::ExtrusionParameters Extrusion::computeFinalParameters()
bool fetched;
Base::Vector3d base;
fetched = fetchAxisLink(this->DirLink, base, dir);
- if (! fetched)
- throw Base::Exception("DirMode is set to use edge, but no edge is linked.");
+ if (!fetched)
+ throw Base::ValueError("DirMode is set to use edge, but no edge is linked.");
this->Dir.setValue(dir);
}break;
case dmNormal:
@@ -198,7 +198,7 @@ Extrusion::ExtrusionParameters Extrusion::computeFinalParameters()
Base::Vector3d Extrusion::calculateShapeNormal(const App::PropertyLink& shapeLink)
{
if (!shapeLink.getValue())
- throw Base::Exception("calculateShapeNormal: link is empty");
+ throw Base::ValueError("calculateShapeNormal: link is empty");
const App::DocumentObject* docobj = shapeLink.getValue();
//special case for sketches and the like: no matter what shape they have, use their local Z axis.
@@ -217,7 +217,7 @@ Base::Vector3d Extrusion::calculateShapeNormal(const App::PropertyLink& shapeLin
const TopoShape &tsh = static_cast(docobj)->Shape.getShape();
TopoDS_Shape sh = tsh.getShape();
if (sh.IsNull())
- throw Base::Exception("calculateShapeNormal: link points to a valid object, but its shape is null.");
+ throw NullShapeException("calculateShapeNormal: link points to a valid object, but its shape is null.");
//find plane
BRepLib_FindSurface planeFinder(sh, -1, /*OnlyPlane=*/true);
@@ -318,7 +318,7 @@ TopoShape Extrusion::extrudeShape(const TopoShape source, Extrusion::ExtrusionPa
}
if (result.IsNull())
- throw Base::Exception("Result of extrusion is null shape.");
+ throw NullShapeException("Result of extrusion is null shape.");
return TopoShape(result);
}
@@ -492,7 +492,7 @@ void Extrusion::makeDraft(ExtrusionParameters params, const TopoDS_Shape& shape,
throw;
}
catch (...) {
- throw Base::Exception("Unknown exception from BRepOffsetAPI_ThruSections");
+ throw Base::CADKernelError("Unknown exception from BRepOffsetAPI_ThruSections");
}
}
}
@@ -519,7 +519,7 @@ void FaceMakerExtrusion::Build()
this->myShape = TopoDS_Shape();
TopoDS_Shape inputShape;
if (mySourceShapes.empty())
- throw Base::Exception("No input shapes!");
+ throw Base::ValueError("No input shapes!");
if (mySourceShapes.size() == 1){
inputShape = mySourceShapes[0];
} else {
diff --git a/src/Mod/Part/App/FeaturePartBoolean.cpp b/src/Mod/Part/App/FeaturePartBoolean.cpp
index 4b567c17d4..4079b94826 100644
--- a/src/Mod/Part/App/FeaturePartBoolean.cpp
+++ b/src/Mod/Part/App/FeaturePartBoolean.cpp
@@ -82,10 +82,10 @@ App::DocumentObjectExecReturn *Boolean::execute(void)
// Now, let's get the TopoDS_Shape
TopoDS_Shape BaseShape = base->Shape.getValue();
if (BaseShape.IsNull())
- throw Base::Exception("Base shape is null");
+ throw NullShapeException("Base shape is null");
TopoDS_Shape ToolShape = tool->Shape.getValue();
if (ToolShape.IsNull())
- throw Base::Exception("Tool shape is null");
+ throw NullShapeException("Tool shape is null");
std::unique_ptr mkBool(makeOperation(BaseShape, ToolShape));
if (!mkBool->IsDone()) {
diff --git a/src/Mod/Part/App/FeaturePartCommon.cpp b/src/Mod/Part/App/FeaturePartCommon.cpp
index 83f47fabc4..2c8471732a 100644
--- a/src/Mod/Part/App/FeaturePartCommon.cpp
+++ b/src/Mod/Part/App/FeaturePartCommon.cpp
@@ -116,7 +116,7 @@ App::DocumentObjectExecReturn *MultiCommon::execute(void)
std::vector history;
TopoDS_Shape resShape = s.front();
if (resShape.IsNull())
- throw Base::RuntimeError("Input shape is null");
+ throw NullShapeException("Input shape is null");
for (std::vector::iterator it = s.begin()+1; it != s.end(); ++it) {
if (it->IsNull())
@@ -126,7 +126,7 @@ App::DocumentObjectExecReturn *MultiCommon::execute(void)
BRepAlgoAPI_Common mkCommon(resShape, *it);
// Let's check if the fusion has been successful
if (!mkCommon.IsDone())
- throw Base::Exception("Intersection failed");
+ throw BooleanException("Intersection failed");
resShape = mkCommon.Shape();
ShapeHistory hist1 = buildHistory(mkCommon, TopAbs_FACE, resShape, mkCommon.Shape1());
@@ -142,7 +142,7 @@ App::DocumentObjectExecReturn *MultiCommon::execute(void)
}
}
if (resShape.IsNull())
- throw Base::Exception("Resulting shape is invalid");
+ throw NullShapeException("Resulting shape is invalid");
Base::Reference hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part/Boolean");
@@ -196,7 +196,7 @@ App::DocumentObjectExecReturn *MultiCommon::execute(void)
}
}
else {
- throw Base::Exception("Not enough shape objects linked");
+ throw Base::CADKernelError("Not enough shape objects linked");
}
return App::DocumentObject::StdReturn;
diff --git a/src/Mod/Part/App/FeaturePartFuse.cpp b/src/Mod/Part/App/FeaturePartFuse.cpp
index fcc8d59bfc..3979cbeb3d 100644
--- a/src/Mod/Part/App/FeaturePartFuse.cpp
+++ b/src/Mod/Part/App/FeaturePartFuse.cpp
@@ -117,16 +117,16 @@ App::DocumentObjectExecReturn *MultiFuse::execute(void)
#if OCC_VERSION_HEX <= 0x060800
TopoDS_Shape resShape = s.front();
if (resShape.IsNull())
- throw Base::Exception("Input shape is null");
+ throw NullShapeException("Input shape is null");
for (std::vector::iterator it = s.begin()+1; it != s.end(); ++it) {
if (it->IsNull())
- throw Base::Exception("Input shape is null");
+ throw NullShapeException("Input shape is null");
// Let's call algorithm computing a fuse operation:
BRepAlgoAPI_Fuse mkFuse(resShape, *it);
// Let's check if the fusion has been successful
if (!mkFuse.IsDone())
- throw Base::Exception("Fusion failed");
+ throw BooleanException("Fusion failed");
resShape = mkFuse.Shape();
ShapeHistory hist1 = buildHistory(mkFuse, TopAbs_FACE, resShape, mkFuse.Shape1());
@@ -222,7 +222,7 @@ App::DocumentObjectExecReturn *MultiFuse::execute(void)
}
}
else {
- throw Base::Exception("Not enough shape objects linked");
+ throw Base::CADKernelError("Not enough shape objects linked");
}
return App::DocumentObject::StdReturn;
diff --git a/src/Mod/Part/App/FeaturePartPolygon.cpp b/src/Mod/Part/App/FeaturePartPolygon.cpp
index e85f2d4a50..37819f7f4d 100644
--- a/src/Mod/Part/App/FeaturePartPolygon.cpp
+++ b/src/Mod/Part/App/FeaturePartPolygon.cpp
@@ -66,7 +66,7 @@ App::DocumentObjectExecReturn *Part::Polygon::execute(void)
poly.Close();
if (!poly.IsDone())
- throw Base::Exception("Cannot create polygon because less than two vetices are given");
+ throw Base::CADKernelError("Cannot create polygon because less than two vertices are given");
TopoDS_Wire wire = poly.Wire();
this->Shape.setValue(wire);
diff --git a/src/Mod/Part/App/Geometry2d.cpp b/src/Mod/Part/App/Geometry2d.cpp
index 58af9bfc46..fb1de909c1 100644
--- a/src/Mod/Part/App/Geometry2d.cpp
+++ b/src/Mod/Part/App/Geometry2d.cpp
@@ -622,8 +622,7 @@ void Geom2dConic::setLocation(const Base::Vector2d& Center)
conic->SetLocation(p1);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -702,8 +701,7 @@ void Geom2dArcOfConic::setLocation(const Base::Vector2d& Center)
conic->SetLocation(p1);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -766,8 +764,7 @@ void Geom2dArcOfConic::setRange(double u, double v)
curve->SetTrim(u, v);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -854,8 +851,7 @@ void Geom2dCircle::setRadius(double Radius)
circle->SetCirc2d(c);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -898,13 +894,12 @@ void Geom2dCircle::Restore(Base::XMLReader& reader)
try {
GCE2d_MakeCircle mc(axis, Radius);
if (!mc.IsDone())
- throw Base::Exception(gce_ErrorStatusText(mc.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(mc.Status()));
this->myCurve = mc.Value();
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -968,8 +963,7 @@ void Geom2dArcOfCircle::setRadius(double Radius)
circle->SetCirc2d(c);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1015,10 +1009,10 @@ void Geom2dArcOfCircle::Restore(Base::XMLReader &reader)
try {
GCE2d_MakeCircle mc(axis, Radius);
if (!mc.IsDone())
- throw Base::Exception(gce_ErrorStatusText(mc.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(mc.Status()));
GCE2d_MakeArcOfCircle ma(mc.Value()->Circ2d(), u, v);
if (!ma.IsDone())
- throw Base::Exception(gce_ErrorStatusText(ma.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(ma.Status()));
Handle(Geom2d_TrimmedCurve) tmpcurve = ma.Value();
Handle(Geom2d_Circle) tmpcircle = Handle(Geom2d_Circle)::DownCast(tmpcurve->BasisCurve());
@@ -1028,8 +1022,7 @@ void Geom2dArcOfCircle::Restore(Base::XMLReader &reader)
this->myCurve->SetTrim(tmpcurve->FirstParameter(), tmpcurve->LastParameter());
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1082,8 +1075,7 @@ void Geom2dEllipse::setMajorRadius(double Radius)
ellipse->SetMajorRadius(Radius);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1101,8 +1093,7 @@ void Geom2dEllipse::setMinorRadius(double Radius)
ellipse->SetMinorRadius(Radius);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1137,8 +1128,7 @@ void Geom2dEllipse::setMajorAxisDir(Base::Vector2d newdir)
myCurve->SetElips2d(e);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1182,13 +1172,12 @@ void Geom2dEllipse::Restore(Base::XMLReader& reader)
try {
GCE2d_MakeEllipse mc(axis, MajorRadius, MinorRadius);
if (!mc.IsDone())
- throw Base::Exception(gce_ErrorStatusText(mc.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(mc.Status()));
this->myCurve = mc.Value();
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1255,8 +1244,7 @@ void Geom2dArcOfEllipse::setMajorRadius(double Radius)
ellipse->SetMajorRadius(Radius);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1274,8 +1262,7 @@ void Geom2dArcOfEllipse::setMinorRadius(double Radius)
ellipse->SetMinorRadius(Radius);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1314,8 +1301,7 @@ void Geom2dArcOfEllipse::setMajorAxisDir(Base::Vector2d newdir)
c->SetElips2d(e);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1363,11 +1349,11 @@ void Geom2dArcOfEllipse::Restore(Base::XMLReader &reader)
try {
GCE2d_MakeEllipse mc(axis, MajorRadius, MinorRadius);
if (!mc.IsDone())
- throw Base::Exception(gce_ErrorStatusText(mc.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(mc.Status()));
GCE2d_MakeArcOfEllipse ma(mc.Value()->Elips2d(), u, v);
if (!ma.IsDone())
- throw Base::Exception(gce_ErrorStatusText(ma.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(ma.Status()));
Handle(Geom2d_TrimmedCurve) tmpcurve = ma.Value();
Handle(Geom2d_Ellipse) tmpellipse = Handle(Geom2d_Ellipse)::DownCast(tmpcurve->BasisCurve());
@@ -1377,8 +1363,7 @@ void Geom2dArcOfEllipse::Restore(Base::XMLReader &reader)
this->myCurve->SetTrim(tmpcurve->FirstParameter(), tmpcurve->LastParameter());
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1431,8 +1416,7 @@ void Geom2dHyperbola::setMajorRadius(double Radius)
h->SetMajorRadius(Radius);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1450,8 +1434,7 @@ void Geom2dHyperbola::setMinorRadius(double Radius)
h->SetMinorRadius(Radius);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1495,13 +1478,12 @@ void Geom2dHyperbola::Restore(Base::XMLReader& reader)
try {
GCE2d_MakeHyperbola mc(axis, MajorRadius, MinorRadius);
if (!mc.IsDone())
- throw Base::Exception(gce_ErrorStatusText(mc.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(mc.Status()));
this->myCurve = mc.Value();
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1563,8 +1545,7 @@ void Geom2dArcOfHyperbola::setMajorRadius(double Radius)
h->SetMajorRadius(Radius);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1582,8 +1563,7 @@ void Geom2dArcOfHyperbola::setMinorRadius(double Radius)
h->SetMinorRadius(Radius);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1631,11 +1611,11 @@ void Geom2dArcOfHyperbola::Restore(Base::XMLReader &reader)
try {
GCE2d_MakeHyperbola mc(axis, MajorRadius, MinorRadius);
if (!mc.IsDone())
- throw Base::Exception(gce_ErrorStatusText(mc.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(mc.Status()));
GCE2d_MakeArcOfHyperbola ma(mc.Value()->Hypr2d(), u, v);
if (!ma.IsDone())
- throw Base::Exception(gce_ErrorStatusText(ma.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(ma.Status()));
Handle(Geom2d_TrimmedCurve) tmpcurve = ma.Value();
Handle(Geom2d_Hyperbola) tmphyperbola = Handle(Geom2d_Hyperbola)::DownCast(tmpcurve->BasisCurve());
@@ -1645,8 +1625,7 @@ void Geom2dArcOfHyperbola::Restore(Base::XMLReader &reader)
this->myCurve->SetTrim(tmpcurve->FirstParameter(), tmpcurve->LastParameter());
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1699,8 +1678,7 @@ void Geom2dParabola::setFocal(double length)
p->SetFocal(length);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1743,13 +1721,12 @@ void Geom2dParabola::Restore(Base::XMLReader& reader)
try {
GCE2d_MakeParabola mc(axis, Focal);
if (!mc.IsDone())
- throw Base::Exception(gce_ErrorStatusText(mc.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(mc.Status()));
this->myCurve = mc.Value();
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1811,8 +1788,7 @@ void Geom2dArcOfParabola::setFocal(double length)
p->SetFocal(length);
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1858,11 +1834,11 @@ void Geom2dArcOfParabola::Restore(Base::XMLReader &reader)
try {
GCE2d_MakeParabola mc(axis, Focal);
if (!mc.IsDone())
- throw Base::Exception(gce_ErrorStatusText(mc.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(mc.Status()));
GCE2d_MakeArcOfParabola ma(mc.Value()->Parab2d(), u, v);
if (!ma.IsDone())
- throw Base::Exception(gce_ErrorStatusText(ma.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(ma.Status()));
Handle(Geom2d_TrimmedCurve) tmpcurve = ma.Value();
Handle(Geom2d_Parabola) tmpparabola = Handle(Geom2d_Parabola)::DownCast(tmpcurve->BasisCurve());
@@ -1872,8 +1848,7 @@ void Geom2dArcOfParabola::Restore(Base::XMLReader &reader)
this->myCurve->SetTrim(tmpcurve->FirstParameter(), tmpcurve->LastParameter());
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -1977,13 +1952,12 @@ void Geom2dLine::Restore(Base::XMLReader &reader)
try {
GCE2d_MakeLine mc(pnt, dir);
if (!mc.IsDone())
- throw Base::Exception(gce_ErrorStatusText(mc.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(mc.Status()));
this->myCurve = mc.Value();
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -2054,7 +2028,7 @@ void Geom2dLineSegment::setPoints(const Base::Vector2d& Start, const Base::Vecto
Standard_Failure::Raise("Both points are equal");
GCE2d_MakeSegment ms(p1, p2);
if (!ms.IsDone()) {
- throw Base::Exception(gce_ErrorStatusText(ms.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(ms.Status()));
}
// get Geom_Line of line segment
@@ -2066,8 +2040,7 @@ void Geom2dLineSegment::setPoints(const Base::Vector2d& Start, const Base::Vecto
this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter());
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -2114,13 +2087,12 @@ void Geom2dLineSegment::Restore(Base::XMLReader &reader)
try {
GCE2d_MakeSegment mc(p1, p2);
if (!mc.IsDone())
- throw Base::Exception(gce_ErrorStatusText(mc.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(mc.Status()));
this->myCurve = mc.Value();
}
catch (Standard_Failure& e) {
-
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
diff --git a/src/Mod/Part/App/ImportIges.cpp b/src/Mod/Part/App/ImportIges.cpp
index df1fe1a147..abc0faeb59 100644
--- a/src/Mod/Part/App/ImportIges.cpp
+++ b/src/Mod/Part/App/ImportIges.cpp
@@ -79,7 +79,7 @@ int Part::ImportIgesParts(App::Document *pcDoc, const char* FileName)
IGESControl_Reader aReader;
if (aReader.ReadFile((Standard_CString)FileName) != IFSelect_RetDone)
- throw Base::Exception("Error in reading IGES");
+ throw Base::FileException("Error in reading IGES");
// Ignore construction elements
// http://www.opencascade.org/org/forum/thread_20603/?forum=3
@@ -204,7 +204,7 @@ int Part::ImportIgesParts(App::Document *pcDoc, const char* FileName)
#endif
}
catch (Standard_Failure& e) {
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
return 0;
diff --git a/src/Mod/Part/App/ImportStep.cpp b/src/Mod/Part/App/ImportStep.cpp
index ea201e17b3..828c27040b 100644
--- a/src/Mod/Part/App/ImportStep.cpp
+++ b/src/Mod/Part/App/ImportStep.cpp
@@ -95,14 +95,14 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name)
if (!fi.exists()) {
std::stringstream str;
str << "File '" << Name << "' does not exist!";
- throw Base::Exception(str.str().c_str());
+ throw Base::FileException(str.str().c_str());
}
std::string encodednamestr = encodeFilename(std::string(Name));
const char * encodedname = encodednamestr.c_str();
if (aReader.ReadFile((Standard_CString)encodedname) !=
IFSelect_RetDone) {
- throw Base::Exception("Cannot open STEP file");
+ throw Base::FileException("Cannot open STEP file");
}
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
@@ -122,7 +122,7 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name)
// Collecting resulting entities
Standard_Integer nbs = aReader.NbShapes();
if (nbs == 0) {
- throw Base::Exception("No shapes found in file ");
+ throw Base::FileException("No shapes found in file ");
}
else {
//Handle(StepData_StepModel) Model = aReader.StepModel();
diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp
index 3f447900ba..6a4b22d391 100644
--- a/src/Mod/Part/App/TopoShape.cpp
+++ b/src/Mod/Part/App/TopoShape.cpp
@@ -224,6 +224,50 @@ const char* BRepBuilderAPI_FaceErrorText(BRepBuilderAPI_FaceError et)
// ------------------------------------------------
+NullShapeException::NullShapeException()
+ : ValueError()
+{
+}
+
+NullShapeException::NullShapeException(const char * sMessage)
+ : ValueError(sMessage)
+{
+}
+
+NullShapeException::NullShapeException(const std::string& sMessage)
+ : ValueError(sMessage)
+{
+}
+
+NullShapeException::NullShapeException(const NullShapeException &inst)
+ : ValueError(inst)
+{
+}
+
+// ------------------------------------------------
+
+BooleanException::BooleanException()
+ : CADKernelError()
+{
+}
+
+BooleanException::BooleanException(const char * sMessage)
+ : CADKernelError(sMessage)
+{
+}
+
+BooleanException::BooleanException(const std::string& sMessage)
+ : CADKernelError(sMessage)
+{
+}
+
+BooleanException::BooleanException(const BooleanException &inst)
+ : CADKernelError(inst)
+{
+}
+
+// ------------------------------------------------
+
TYPESYSTEM_SOURCE(Part::ShapeSegment , Data::Segment);
std::string ShapeSegment::getName() const
@@ -233,7 +277,7 @@ std::string ShapeSegment::getName() const
// ------------------------------------------------
-TYPESYSTEM_SOURCE(Part::TopoShape , Data::ComplexGeoData);
+TYPESYSTEM_SOURCE(Part::TopoShape , Data::ComplexGeoData)
TopoShape::TopoShape()
{
@@ -489,7 +533,7 @@ void TopoShape::read(const char *FileName)
importBrep(File.filePath().c_str());
}
else{
- throw Base::Exception("Unknown extension");
+ throw Base::FileException("Unknown extension");
}
}
@@ -537,7 +581,7 @@ void TopoShape::importIges(const char *FileName)
// http://www.opencascade.org/org/forum/thread_20603/?forum=3
aReader.SetReadVisible(Standard_True);
if (aReader.ReadFile(encodeFilename(FileName).c_str()) != IFSelect_RetDone)
- throw Base::Exception("Error in reading IGES");
+ throw Base::FileException("Error in reading IGES");
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
pi->NewScope(100, "Reading IGES file...");
@@ -552,7 +596,7 @@ void TopoShape::importIges(const char *FileName)
pi->EndScope();
}
catch (Standard_Failure& e) {
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -561,7 +605,7 @@ void TopoShape::importStep(const char *FileName)
try {
STEPControl_Reader aReader;
if (aReader.ReadFile(encodeFilename(FileName).c_str()) != IFSelect_RetDone)
- throw Base::Exception("Error in reading STEP");
+ throw Base::FileException("Error in reading STEP");
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
aReader.WS()->MapReader()->SetProgress(pi);
@@ -575,7 +619,7 @@ void TopoShape::importStep(const char *FileName)
pi->EndScope();
}
catch (Standard_Failure& e) {
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -597,7 +641,7 @@ void TopoShape::importBrep(const char *FileName)
this->_Shape = aShape;
}
catch (Standard_Failure& e) {
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -622,10 +666,10 @@ void TopoShape::importBrep(std::istream& str, int indicator)
this->_Shape = aShape;
}
catch (Standard_Failure& e) {
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
catch (const std::exception& e) {
- throw Base::Exception(e.what());
+ throw Base::CADKernelError(e.what());
}
}
@@ -672,7 +716,7 @@ void TopoShape::write(const char *FileName) const
exportStl(File.filePath().c_str(),0);
}
else{
- throw Base::Exception("Unknown extension");
+ throw Base::FileException("Unknown extension");
}
}
@@ -690,10 +734,10 @@ void TopoShape::exportIges(const char *filename) const
aWriter.AddShape(this->_Shape);
aWriter.ComputeModel();
if (aWriter.Write(encodeFilename(filename).c_str()) != IFSelect_RetDone)
- throw Base::Exception("Writing of IGES failed");
+ throw Base::FileException("Writing of IGES failed");
}
catch (Standard_Failure& e) {
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
@@ -711,7 +755,7 @@ void TopoShape::exportStep(const char *filename) const
pi->Show();
if (aWriter.Transfer(this->_Shape, STEPControl_AsIs) != IFSelect_RetDone)
- throw Base::Exception("Error in transferring STEP");
+ throw Base::FileException("Error in transferring STEP");
APIHeaderSection_MakeHeader makeHeader(aWriter.Model());
makeHeader.SetName(new TCollection_HAsciiString((Standard_CString)(encodeFilename(filename).c_str())));
@@ -721,18 +765,18 @@ void TopoShape::exportStep(const char *filename) const
makeHeader.SetDescriptionValue(1, new TCollection_HAsciiString("FreeCAD Model"));
if (aWriter.Write(encodeFilename(filename).c_str()) != IFSelect_RetDone)
- throw Base::Exception("Writing of STEP failed");
+ throw Base::FileException("Writing of STEP failed");
pi->EndScope();
}
catch (Standard_Failure& e) {
- throw Base::Exception(e.GetMessageString());
+ throw Base::CADKernelError(e.GetMessageString());
}
}
void TopoShape::exportBrep(const char *filename) const
{
if (!BRepTools::Write(this->_Shape,encodeFilename(filename).c_str()))
- throw Base::Exception("Writing of BREP failed");
+ throw Base::FileException("Writing of BREP failed");
}
void TopoShape::exportBrep(std::ostream& out) const
@@ -1593,7 +1637,7 @@ TopoDS_Shape TopoShape::fuse(const std::vector& shapes, Standard_R
throw Base::ValueError("Object shape is null");
for (std::vector::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
if (it->IsNull())
- throw Base::Exception("Input shape is null");
+ throw NullShapeException("Input shape is null");
// Let's call algorithm computing a fuse operation:
BRepAlgoAPI_Fuse mkFuse(resShape, *it);
// Let's check if the fusion has been successful
@@ -1610,7 +1654,7 @@ TopoDS_Shape TopoShape::fuse(const std::vector& shapes, Standard_R
shapeArguments.Append(this->_Shape);
for (std::vector::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
if (it->IsNull())
- throw Base::Exception("Tool shape is null");
+ throw NullShapeException("Tool shape is null");
if (tolerance > 0.0)
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
shapeTools.Append(BRepBuilderAPI_Copy(*it).Shape());
@@ -1752,7 +1796,7 @@ TopoDS_Shape TopoShape::generalFuse(const std::vector &sOthers, St
GFAArguments.Append(this->_Shape);
for (const TopoDS_Shape &it: sOthers) {
if (it.IsNull())
- throw Base::Exception("Tool shape is null");
+ throw NullShapeException("Tool shape is null");
if (tolerance > 0.0)
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
GFAArguments.Append(BRepBuilderAPI_Copy(it).Shape());
@@ -1767,7 +1811,7 @@ TopoDS_Shape TopoShape::generalFuse(const std::vector &sOthers, St
#endif
mkGFA.Build();
if (!mkGFA.IsDone())
- throw Base::Exception("MultiFusion failed");
+ throw BooleanException("MultiFusion failed");
TopoDS_Shape resShape = mkGFA.Shape();
if (mapInOut){
for(TopTools_ListIteratorOfListOfShape it(GFAArguments); it.More(); it.Next()){
@@ -2546,7 +2590,7 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
builder.Add(compoundSourceWires, w);
BRepLib_FindSurface planefinder(compoundSourceWires, -1, Standard_True);
if (!planefinder.Found())
- throw Base::Exception("makeOffset2D: wires are nonplanar or noncoplanar");
+ throw Base::CADKernelError("makeOffset2D: wires are nonplanar or noncoplanar");
if (haveFaces){
//extract plane from first face (useful for preserving the plane of face precisely if dealing with only one face)
workingPlane = BRepAdaptor_Surface(TopoDS::Face(shapesToProcess[0])).Plane();
@@ -2577,12 +2621,12 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
throw;
}
catch (...) {
- throw Base::Exception("BRepOffsetAPI_MakeOffset has crashed! (Unknown exception caught)");
+ throw Base::CADKernelError("BRepOffsetAPI_MakeOffset has crashed! (Unknown exception caught)");
}
offsetShape = mkOffset.Shape();
if(offsetShape.IsNull())
- throw Base::Exception("makeOffset2D: result of offsetting is null!");
+ throw Base::CADKernelError("makeOffset2D: result of offsetting is null!");
//Copying shape to fix strange orientation behavior, OCC7.0.0. See bug #2699
// http://www.freecadweb.org/tracker/view.php?id=2699
@@ -2601,7 +2645,7 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
}
if (offsetWires.empty())
- throw Base::Exception("makeOffset2D: offset result has no wires.");
+ throw Base::CADKernelError("makeOffset2D: offset result has no wires.");
std::list wiresForMakingFaces;
if (!fill){
@@ -2650,7 +2694,7 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
//for now, only support offsetting one open wire -> there should be exactly two open wires for connecting
if (openWires.size() != 2)
- throw Base::Exception("makeOffset2D: collective offset with filling of multiple wires is not supported yet.");
+ throw Base::CADKernelError("makeOffset2D: collective offset with filling of multiple wires is not supported yet.");
TopoDS_Wire openWire1 = openWires.front();
TopoDS_Wire openWire2 = openWires.back();
@@ -2669,10 +2713,10 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
TopoDS_Vertex v4 = xp.CurrentVertex();
//check
- if (v1.IsNull()) throw Base::Exception("v1 is null");
- if (v2.IsNull()) throw Base::Exception("v2 is null");
- if (v3.IsNull()) throw Base::Exception("v3 is null");
- if (v4.IsNull()) throw Base::Exception("v4 is null");
+ if (v1.IsNull()) throw NullShapeException("v1 is null");
+ if (v2.IsNull()) throw NullShapeException("v2 is null");
+ if (v3.IsNull()) throw NullShapeException("v3 is null");
+ if (v4.IsNull()) throw NullShapeException("v4 is null");
//assemble new wire
@@ -2688,7 +2732,7 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
} else if ((fabs(gp_Vec(BRep_Tool::Pnt(v2), BRep_Tool::Pnt(v4)).Magnitude() - fabs(offset)) <= BRep_Tool::Tolerance(v2) + BRep_Tool::Tolerance(v4))){
//orientation is as expected, nothing to do
} else {
- throw Base::Exception("makeOffset2D: fill offset: failed to establish open vertex relationship.");
+ throw Base::CADKernelError("makeOffset2D: fill offset: failed to establish open vertex relationship.");
}
//now directions of open wires are aligned. Finally. make new wire!
@@ -2723,7 +2767,7 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
}
mkFace.Build();
if (mkFace.Shape().IsNull())
- throw Base::Exception("makeOffset2D: making face failed (null shape returned).");
+ throw Base::CADKernelError("makeOffset2D: making face failed (null shape returned).");
TopoDS_Shape result = mkFace.Shape();
if (haveFaces && shapesToProcess.size() == 1)
result.Orientation(shapesToProcess[0].Orientation());
diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h
index ce9cb6fab9..1738cb8bd0 100644
--- a/src/Mod/Part/App/TopoShape.h
+++ b/src/Mod/Part/App/TopoShape.h
@@ -29,6 +29,7 @@
#include
#include
#include
+#include
class gp_Ax1;
class gp_Ax2;
@@ -37,6 +38,36 @@ class gp_Vec;
namespace Part
{
+/* A special sub-class to indicate null shapes
+ */
+class PartExport NullShapeException : public Base::ValueError
+{
+public:
+ /// Construction
+ NullShapeException();
+ NullShapeException(const char * sMessage);
+ NullShapeException(const std::string& sMessage);
+ /// Construction
+ NullShapeException(const NullShapeException &inst);
+ /// Destruction
+ virtual ~NullShapeException() throw() {}
+};
+
+/* A special sub-class to indicate boolean failures
+ */
+class PartExport BooleanException : public Base::CADKernelError
+{
+public:
+ /// Construction
+ BooleanException();
+ BooleanException(const char * sMessage);
+ BooleanException(const std::string& sMessage);
+ /// Construction
+ BooleanException(const BooleanException &inst);
+ /// Destruction
+ virtual ~BooleanException() throw() {}
+};
+
class PartExport ShapeSegment : public Data::Segment
{
TYPESYSTEM_HEADER();
diff --git a/src/Mod/Part/App/TopoShapeFacePyImp.cpp b/src/Mod/Part/App/TopoShapeFacePyImp.cpp
index 6dcf53f4cc..8201f66885 100644
--- a/src/Mod/Part/App/TopoShapeFacePyImp.cpp
+++ b/src/Mod/Part/App/TopoShapeFacePyImp.cpp
@@ -142,7 +142,6 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return -1;
}
@@ -175,7 +174,6 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
return 0;
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return -1;
}
@@ -208,7 +206,6 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
return 0;
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return -1;
}
@@ -254,7 +251,6 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
return 0;
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return -1;
}
@@ -314,7 +310,6 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return -1;
}
@@ -343,7 +338,7 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
} else if (PyObject_TypeCheck(pcPyShapeOrList, &(Part::TopoShapePy::Type))) {
const TopoDS_Shape& sh = static_cast(pcPyShapeOrList)->getTopoShapePtr()->getShape();
if (sh.IsNull())
- throw Base::Exception("Shape is null!");
+ throw NullShapeException("Shape is null!");
if (sh.ShapeType() == TopAbs_COMPOUND)
fm->useCompound(TopoDS::Compound(sh));
else
@@ -539,7 +534,6 @@ PyObject* TopoShapeFacePy::derivative1At(PyObject *args)
return Py::new_reference_to(tuple);
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return 0;
}
@@ -564,7 +558,6 @@ PyObject* TopoShapeFacePy::derivative2At(PyObject *args)
return Py::new_reference_to(tuple);
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return 0;
}
@@ -591,7 +584,6 @@ PyObject* TopoShapeFacePy::isPartOfDomain(PyObject *args)
return PyBool_FromLong((state == TopAbs_ON || state == TopAbs_IN) ? 1 : 0);
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return 0;
}
@@ -609,7 +601,6 @@ PyObject* TopoShapeFacePy::makeHalfSpace(PyObject *args)
return new TopoShapeSolidPy(new TopoShape(mkHS.Solid()));
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return 0;
}
@@ -661,7 +652,6 @@ PyObject* TopoShapeFacePy::validate(PyObject *args)
Py_Return;
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return 0;
}
@@ -696,7 +686,6 @@ PyObject* TopoShapeFacePy::curveOnSurface(PyObject *args)
return Py::new_reference_to(tuple);
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return 0;
}
diff --git a/src/Mod/Part/App/TopoShapeShellPyImp.cpp b/src/Mod/Part/App/TopoShapeShellPyImp.cpp
index 8999998e49..8cc4cd7d16 100644
--- a/src/Mod/Part/App/TopoShapeShellPyImp.cpp
+++ b/src/Mod/Part/App/TopoShapeShellPyImp.cpp
@@ -112,7 +112,6 @@ int TopoShapeShellPy::PyInit(PyObject* args, PyObject* /*kwd*/)
Standard_Failure::Raise("Shape is not a shell");
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return -1;
}
@@ -146,7 +145,6 @@ PyObject* TopoShapeShellPy::add(PyObject *args)
}
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return 0;
}
@@ -198,7 +196,6 @@ PyObject* TopoShapeShellPy::makeHalfSpace(PyObject *args)
return new TopoShapeSolidPy(new TopoShape(mkHS.Solid()));
}
catch (Standard_Failure& e) {
-
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return 0;
}
diff --git a/src/Mod/Part/Gui/AttacherTexts.cpp b/src/Mod/Part/Gui/AttacherTexts.cpp
index be6d150154..dde4144a22 100644
--- a/src/Mod/Part/Gui/AttacherTexts.cpp
+++ b/src/Mod/Part/Gui/AttacherTexts.cpp
@@ -349,7 +349,7 @@ QString getShapeTypeText(eRefType type)
}
}
- throw Base::Exception("getShTypeText: type value is wrong, or a string is missing in the list");
+ throw Base::TypeError("getShTypeText: type value is wrong, or a string is missing in the list");
}
QStringList getRefListForMode(AttachEngine &attacher, eMapMode mmode)
diff --git a/src/Mod/Part/Gui/DlgExtrusion.cpp b/src/Mod/Part/Gui/DlgExtrusion.cpp
index ffad75b6e2..e631bea555 100644
--- a/src/Mod/Part/Gui/DlgExtrusion.cpp
+++ b/src/Mod/Part/Gui/DlgExtrusion.cpp
@@ -276,7 +276,7 @@ App::DocumentObject& DlgExtrusion::getShapeToExtrude() const
{
std::vector objs = this->getShapesToExtrude();
if (objs.size() == 0)
- throw Base::Exception("No shapes selected");
+ throw Base::ValueError("No shapes selected");
return *(objs[0]);
}
@@ -584,13 +584,13 @@ std::vector DlgExtrusion::getShapesToExtrude() const
QList items = ui->treeWidget->selectedItems();
App::Document* doc = App::GetApplication().getDocument(this->document.c_str());
if (!doc)
- throw Base::Exception("Document lost");
+ throw Base::RuntimeError("Document lost");
std::vector objects;
for (int i = 0; i < items.size(); i++) {
App::DocumentObject* obj = doc->getObject(items[i]->data(0, Qt::UserRole).toString().toLatin1());
if (!obj)
- throw Base::Exception("Object not found");
+ throw Base::RuntimeError("Object not found");
objects.push_back(obj);
}
return objects;
diff --git a/src/Mod/Part/Gui/DlgPrimitives.cpp b/src/Mod/Part/Gui/DlgPrimitives.cpp
index c044b45f18..e9469f5ad5 100644
--- a/src/Mod/Part/Gui/DlgPrimitives.cpp
+++ b/src/Mod/Part/Gui/DlgPrimitives.cpp
@@ -154,7 +154,7 @@ public:
{
GC_MakeArcOfCircle arc(points[0], points[1], points[2]);
if (!arc.IsDone())
- throw Base::Exception(gce_ErrorStatusText(arc.Status()));
+ throw Base::CADKernelError(gce_ErrorStatusText(arc.Status()));
Handle(Geom_TrimmedCurve) trim = arc.Value();
Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(trim->BasisCurve());
diff --git a/src/Mod/Part/Gui/DlgRevolution.cpp b/src/Mod/Part/Gui/DlgRevolution.cpp
index e6c2c95159..86b2b14a73 100644
--- a/src/Mod/Part/Gui/DlgRevolution.cpp
+++ b/src/Mod/Part/Gui/DlgRevolution.cpp
@@ -234,13 +234,13 @@ std::vector DlgRevolution::getShapesToRevolve() const
QList items = ui->treeWidget->selectedItems();
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc)
- throw Base::Exception("Document lost");
+ throw Base::RuntimeError("Document lost");
std::vector objects;
for (int i = 0; i < items.size(); i++) {
App::DocumentObject* obj = doc->getObject(items[i]->data(0, Qt::UserRole).toString().toLatin1());
if (!obj)
- throw Base::Exception("Object not found");
+ throw Base::RuntimeError("Object not found");
objects.push_back(obj);
}
return objects;
@@ -514,7 +514,7 @@ App::DocumentObject&DlgRevolution::getShapeToRevolve() const
{
std::vector objs = this->getShapesToRevolve();
if (objs.size() == 0)
- throw Base::Exception("No shapes selected");
+ throw Base::ValueError("No shapes selected");
return *(objs[0]);
}
diff --git a/src/Mod/Part/Gui/TaskLoft.cpp b/src/Mod/Part/Gui/TaskLoft.cpp
index 9ad40026d6..ab212ed354 100644
--- a/src/Mod/Part/Gui/TaskLoft.cpp
+++ b/src/Mod/Part/Gui/TaskLoft.cpp
@@ -197,7 +197,8 @@ bool LoftWidget::accept()
).arg(list).arg(solid).arg(ruled).arg(closed).arg(QString::fromLatin1(d->document.c_str()));
Gui::Document* doc = Gui::Application::Instance->getDocument(d->document.c_str());
- if (!doc) throw Base::Exception("Document doesn't exist anymore");
+ if (!doc)
+ throw Base::RuntimeError("Document doesn't exist anymore");
doc->openCommand("Loft");
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
doc->getDocument()->recompute();
@@ -205,7 +206,7 @@ bool LoftWidget::accept()
if (obj && !obj->isValid()) {
std::string msg = obj->getStatusString();
doc->abortCommand();
- throw Base::Exception(msg);
+ throw Base::RuntimeError(msg);
}
doc->commitCommand();
}
diff --git a/src/Mod/Part/Gui/TaskOffset.cpp b/src/Mod/Part/Gui/TaskOffset.cpp
index 2d38187788..d32e6a47eb 100644
--- a/src/Mod/Part/Gui/TaskOffset.cpp
+++ b/src/Mod/Part/Gui/TaskOffset.cpp
@@ -196,7 +196,7 @@ bool OffsetWidget::accept()
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (!d->offset->isValid())
- throw Base::Exception(d->offset->getStatusString());
+ throw Base::CADKernelError(d->offset->getStatusString());
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
Gui::Command::commitCommand();
}
diff --git a/src/Mod/Part/Gui/TaskSweep.cpp b/src/Mod/Part/Gui/TaskSweep.cpp
index 375c9b992a..28bc3c00f7 100644
--- a/src/Mod/Part/Gui/TaskSweep.cpp
+++ b/src/Mod/Part/Gui/TaskSweep.cpp
@@ -338,7 +338,8 @@ bool SweepWidget::accept()
.arg(QString::fromLatin1(d->document.c_str()));
Gui::Document* doc = Gui::Application::Instance->getDocument(d->document.c_str());
- if (!doc) throw Base::Exception("Document doesn't exist anymore");
+ if (!doc)
+ throw Base::RuntimeError("Document doesn't exist anymore");
doc->openCommand("Sweep");
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
doc->getDocument()->recompute();
@@ -346,7 +347,7 @@ bool SweepWidget::accept()
if (obj && !obj->isValid()) {
std::string msg = obj->getStatusString();
doc->abortCommand();
- throw Base::Exception(msg);
+ throw Base::RuntimeError(msg);
}
doc->commitCommand();
}
diff --git a/src/Mod/Part/Gui/TaskThickness.cpp b/src/Mod/Part/Gui/TaskThickness.cpp
index 622a1d70cf..d22068dcf4 100644
--- a/src/Mod/Part/Gui/TaskThickness.cpp
+++ b/src/Mod/Part/Gui/TaskThickness.cpp
@@ -225,7 +225,7 @@ bool ThicknessWidget::accept()
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (!d->thickness->isValid())
- throw Base::Exception(d->thickness->getStatusString());
+ throw Base::CADKernelError(d->thickness->getStatusString());
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
Gui::Command::commitCommand();
}