fixes #0001422: Subclass Exception
inherit Base.FreeCADError form RuntimeError inherit Part.OCCError from Base.FreeCADError inherit OCCDomainError from Part.OCCError inherit OCCRangeError from Part.OCCError inherit OCCConstructionError from OCCDomainError inherit OCCDimensionError from OCCDomainError Added PY_CATCH_OCC macro replace PyExc_Exception use FreeCADError in makeWireString catch exception in BSplineCurve.increasedegree
This commit is contained in:
@@ -99,6 +99,7 @@
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObjectPy.h>
|
||||
|
||||
#include "OCCError.h"
|
||||
#include "TopoShape.h"
|
||||
#include "TopoShapePy.h"
|
||||
#include "TopoShapeEdgePy.h"
|
||||
@@ -188,7 +189,7 @@ static PyObject * open(PyObject *self, PyObject *args)
|
||||
Py_Error(PyExc_Exception, e.what());
|
||||
}
|
||||
}
|
||||
} PY_CATCH;
|
||||
} PY_CATCH_OCC;
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
@@ -243,7 +244,7 @@ static PyObject * insert(PyObject *self, PyObject *args)
|
||||
Py_Error(PyExc_Exception, e.what());
|
||||
}
|
||||
}
|
||||
} PY_CATCH;
|
||||
} PY_CATCH_OCC;
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
@@ -281,7 +282,7 @@ static PyObject * exporter(PyObject *self, PyObject *args)
|
||||
TopoShape shape(comp);
|
||||
shape.write(filename);
|
||||
|
||||
} PY_CATCH;
|
||||
} PY_CATCH_OCC;
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
@@ -296,7 +297,7 @@ static PyObject * read(PyObject *self, PyObject *args)
|
||||
TopoShape* shape = new TopoShape();
|
||||
shape->read(Name);
|
||||
return new TopoShapePy(shape);
|
||||
} PY_CATCH;
|
||||
} PY_CATCH_OCC;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
@@ -316,7 +317,7 @@ show(PyObject *self, PyObject *args)
|
||||
//TopoShape* shape = new MeshObject(*pShape->getTopoShapeObjectPtr());
|
||||
pcFeature->Shape.setValue(pShape->getTopoShapePtr()->_Shape);
|
||||
pcDoc->recompute();
|
||||
} PY_CATCH;
|
||||
} PY_CATCH_OCC;
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
@@ -382,11 +383,11 @@ static PyObject * makeWireString(PyObject *self, PyObject *args)
|
||||
CharList = FT2FC(unichars,pysize,dir,fontfile,height,track); }
|
||||
}
|
||||
catch (Standard_DomainError) { // Standard_DomainError is OCC error.
|
||||
PyErr_SetString(PyExc_Exception, "makeWireString failed - Standard_DomainError");
|
||||
PyErr_SetString(PartExceptionOCCDomainError, "makeWireString failed - Standard_DomainError");
|
||||
return NULL;
|
||||
}
|
||||
catch (std::runtime_error& e) { // FT2 or FT2FC errors
|
||||
PyErr_SetString(PyExc_Exception, e.what());
|
||||
PyErr_SetString(PartExceptionOCCError, e.what());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -396,7 +397,7 @@ static PyObject * makeWireString(PyObject *self, PyObject *args)
|
||||
|
||||
static PyObject * makeWireString(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyErr_SetString(PyExc_Exception, "FreeCAD compiled without FreeType support! This method is disabled...");
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "FreeCAD compiled without FreeType support! This method is disabled...");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -426,12 +427,12 @@ makeCompound(PyObject *self, PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
return new TopoShapeCompoundPy(new TopoShape(Comp));
|
||||
} PY_CATCH;
|
||||
} PY_CATCH_OCC;
|
||||
}
|
||||
|
||||
static PyObject * makeFilledFace(PyObject *self, PyObject *args)
|
||||
@@ -482,7 +483,7 @@ static PyObject * makeFilledFace(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
if (numConstraints == 0) {
|
||||
PyErr_SetString(PyExc_Exception, "Failed to created face with no constraints");
|
||||
PyErr_SetString(PartExceptionOCCError, "Failed to created face with no constraints");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -491,16 +492,16 @@ static PyObject * makeFilledFace(PyObject *self, PyObject *args)
|
||||
return new TopoShapeFacePy(new TopoShape(builder.Face()));
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_Exception, "Failed to created face by filling edges");
|
||||
PyErr_SetString(PartExceptionOCCError, "Failed to created face by filling edges");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
} PY_CATCH;
|
||||
} PY_CATCH_OCC;
|
||||
}
|
||||
|
||||
static PyObject * makeShell(PyObject *self, PyObject *args)
|
||||
@@ -536,12 +537,12 @@ static PyObject * makeShell(PyObject *self, PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
return new TopoShapeShellPy(new TopoShape(shape));
|
||||
} PY_CATCH;
|
||||
} PY_CATCH_OCC;
|
||||
}
|
||||
|
||||
static PyObject * makeSolid(PyObject *self, PyObject *args)
|
||||
@@ -569,7 +570,7 @@ static PyObject * makeSolid(PyObject *self, PyObject *args)
|
||||
return new TopoShapeSolidPy(new TopoShape(solid));
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of solid failed");
|
||||
PyErr_SetString(PartExceptionOCCError, "creation of solid failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -585,11 +586,11 @@ static PyObject * makePlane(PyObject *self, PyObject *args)
|
||||
return NULL;
|
||||
|
||||
if (length < Precision::Confusion()) {
|
||||
PyErr_SetString(PyExc_Exception, "length of plane too small");
|
||||
PyErr_SetString(PartExceptionOCCError, "length of plane too small");
|
||||
return NULL;
|
||||
}
|
||||
if (width < Precision::Confusion()) {
|
||||
PyErr_SetString(PyExc_Exception, "width of plane too small");
|
||||
PyErr_SetString(PartExceptionOCCError, "width of plane too small");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -623,11 +624,11 @@ static PyObject * makePlane(PyObject *self, PyObject *args)
|
||||
return new TopoShapeFacePy(new TopoShape((Face.Face())));
|
||||
}
|
||||
catch (Standard_DomainError) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of plane failed");
|
||||
PyErr_SetString(PartExceptionOCCDomainError, "creation of plane failed");
|
||||
return NULL;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of plane failed");
|
||||
PyErr_SetString(PartExceptionOCCError, "creation of plane failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -642,15 +643,15 @@ static PyObject * makeBox(PyObject *self, PyObject *args)
|
||||
return NULL;
|
||||
|
||||
if (length < Precision::Confusion()) {
|
||||
PyErr_SetString(PyExc_Exception, "length of box too small");
|
||||
PyErr_SetString(PartExceptionOCCError, "length of box too small");
|
||||
return NULL;
|
||||
}
|
||||
if (width < Precision::Confusion()) {
|
||||
PyErr_SetString(PyExc_Exception, "width of box too small");
|
||||
PyErr_SetString(PartExceptionOCCError, "width of box too small");
|
||||
return NULL;
|
||||
}
|
||||
if (height < Precision::Confusion()) {
|
||||
PyErr_SetString(PyExc_Exception, "height of box too small");
|
||||
PyErr_SetString(PartExceptionOCCError, "height of box too small");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -670,7 +671,7 @@ static PyObject * makeBox(PyObject *self, PyObject *args)
|
||||
return new TopoShapeSolidPy(new TopoShape(ResultShape));
|
||||
}
|
||||
catch (Standard_DomainError) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of box failed");
|
||||
PyErr_SetString(PartExceptionOCCDomainError, "creation of box failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -690,23 +691,23 @@ static PyObject * makeWedge(PyObject *self, PyObject *args)
|
||||
double dz2 = z2max-z2min;
|
||||
double dx2 = x2max-x2min;
|
||||
if (dx < Precision::Confusion()) {
|
||||
PyErr_SetString(PyExc_Exception, "delta x of wedge too small");
|
||||
PyErr_SetString(PartExceptionOCCError, "delta x of wedge too small");
|
||||
return NULL;
|
||||
}
|
||||
if (dy < Precision::Confusion()) {
|
||||
PyErr_SetString(PyExc_Exception, "delta y of wedge too small");
|
||||
PyErr_SetString(PartExceptionOCCError, "delta y of wedge too small");
|
||||
return NULL;
|
||||
}
|
||||
if (dz < Precision::Confusion()) {
|
||||
PyErr_SetString(PyExc_Exception, "delta z of wedge too small");
|
||||
PyErr_SetString(PartExceptionOCCError, "delta z of wedge too small");
|
||||
return NULL;
|
||||
}
|
||||
if (dz2 < 0) {
|
||||
PyErr_SetString(PyExc_Exception, "delta z2 of wedge is negative");
|
||||
PyErr_SetString(PartExceptionOCCError, "delta z2 of wedge is negative");
|
||||
return NULL;
|
||||
}
|
||||
if (dx2 < 0) {
|
||||
PyErr_SetString(PyExc_Exception, "delta x2 of wedge is negative");
|
||||
PyErr_SetString(PartExceptionOCCError, "delta x2 of wedge is negative");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -727,7 +728,7 @@ static PyObject * makeWedge(PyObject *self, PyObject *args)
|
||||
return new TopoShapeSolidPy(new TopoShape(mkSolid.Solid()));
|
||||
}
|
||||
catch (Standard_DomainError) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of wedge failed");
|
||||
PyErr_SetString(PartExceptionOCCDomainError, "creation of wedge failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -764,7 +765,7 @@ static PyObject * makeCircle(PyObject *self, PyObject *args)
|
||||
return new TopoShapeEdgePy(new TopoShape(edge));
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of circle failed");
|
||||
PyErr_SetString(PartExceptionOCCError, "creation of circle failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -795,7 +796,7 @@ static PyObject * makeSphere(PyObject *self, PyObject *args)
|
||||
return new TopoShapeSolidPy(new TopoShape(shape));
|
||||
}
|
||||
catch (Standard_DomainError) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of sphere failed");
|
||||
PyErr_SetString(PartExceptionOCCDomainError, "creation of sphere failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -826,7 +827,7 @@ static PyObject * makeCylinder(PyObject *self, PyObject *args)
|
||||
return new TopoShapeSolidPy(new TopoShape(shape));
|
||||
}
|
||||
catch (Standard_DomainError) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of cylinder failed");
|
||||
PyErr_SetString(PartExceptionOCCDomainError, "creation of cylinder failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -857,7 +858,7 @@ static PyObject * makeCone(PyObject *self, PyObject *args)
|
||||
return new TopoShapeSolidPy(new TopoShape(shape));
|
||||
}
|
||||
catch (Standard_DomainError) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of cone failed");
|
||||
PyErr_SetString(PartExceptionOCCDomainError, "creation of cone failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -888,7 +889,7 @@ static PyObject * makeTorus(PyObject *self, PyObject *args)
|
||||
return new TopoShapeSolidPy(new TopoShape(shape));
|
||||
}
|
||||
catch (Standard_DomainError) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of torus failed");
|
||||
PyErr_SetString(PartExceptionOCCDomainError, "creation of torus failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -913,7 +914,7 @@ static PyObject * makeHelix(PyObject *self, PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -936,7 +937,7 @@ static PyObject * makeLongHelix(PyObject *self, PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -954,7 +955,7 @@ static PyObject * makeThread(PyObject *self, PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1027,7 +1028,7 @@ static PyObject * makeLine(PyObject *self, PyObject *args)
|
||||
}
|
||||
// Error
|
||||
if (error) {
|
||||
PyErr_SetString(PyExc_RuntimeError, error);
|
||||
PyErr_SetString(PartExceptionOCCError, error);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1076,10 +1077,10 @@ static PyObject * makePolygon(PyObject *self, PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
} PY_CATCH;
|
||||
} PY_CATCH_OCC;
|
||||
}
|
||||
|
||||
static PyObject * makeRevolution(PyObject *self, PyObject *args)
|
||||
@@ -1117,12 +1118,12 @@ static PyObject * makeRevolution(PyObject *self, PyObject *args)
|
||||
}
|
||||
const TopoDS_Shape& shape = static_cast<TopoShapePy*>(pCrv)->getTopoShapePtr()->_Shape;
|
||||
if (shape.IsNull()) {
|
||||
PyErr_SetString(PyExc_Exception, "shape is empty");
|
||||
PyErr_SetString(PartExceptionOCCError, "shape is empty");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (shape.ShapeType() != TopAbs_EDGE) {
|
||||
PyErr_SetString(PyExc_Exception, "shape is not an edge");
|
||||
PyErr_SetString(PartExceptionOCCError, "shape is not an edge");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1134,7 +1135,7 @@ static PyObject * makeRevolution(PyObject *self, PyObject *args)
|
||||
TopLoc_Location loc = edge.Location();
|
||||
curve = Handle_Geom_Curve::DownCast(hCurve->Transformed(loc.Transformation()));
|
||||
if (curve.IsNull()) {
|
||||
PyErr_SetString(PyExc_Exception, "invalid curve in edge");
|
||||
PyErr_SetString(PartExceptionOCCError, "invalid curve in edge");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1178,7 +1179,7 @@ static PyObject * makeRevolution(PyObject *self, PyObject *args)
|
||||
}
|
||||
}
|
||||
catch (Standard_DomainError) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of revolved shape failed");
|
||||
PyErr_SetString(PartExceptionOCCDomainError, "creation of revolved shape failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -1204,12 +1205,12 @@ static PyObject * makeRuledSurface(PyObject *self, PyObject *args)
|
||||
return new TopoShapeShellPy(new TopoShape(shell));
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_Exception, "curves must either be edges or wires");
|
||||
PyErr_SetString(PartExceptionOCCError, "curves must either be edges or wires");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of ruled surface failed");
|
||||
PyErr_SetString(PartExceptionOCCError, "creation of ruled surface failed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1236,7 +1237,7 @@ static PyObject * makeSweepSurface(PyObject *self, PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1280,7 +1281,7 @@ static PyObject * makeTube(PyObject *self, PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1321,7 +1322,7 @@ static PyObject * makeLoft(PyObject *self, PyObject *args)
|
||||
anAlgo.Perform (aLine, aSecGenerator);
|
||||
|
||||
if (!anAlgo.IsDone()) {
|
||||
PyErr_SetString(PyExc_Exception, "Failed to create loft surface");
|
||||
PyErr_SetString(PartExceptionOCCError, "Failed to create loft surface");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1365,7 +1366,7 @@ static PyObject * makeLoft(PyObject *self, PyObject *args)
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
Base::Console().Message("debug: Part.makeLoft catching 'Standard_Failure' msg: '%s'\n", e->GetMessageString());
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -1449,7 +1450,7 @@ static PyObject * toPythonOCC(PyObject *self, PyObject *args)
|
||||
return proxy;
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_Exception, e.what());
|
||||
PyErr_SetString(PartExceptionOCCError, e.what());
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -1469,7 +1470,7 @@ static PyObject * fromPythonOCC(PyObject *self, PyObject *args)
|
||||
return new TopoShapePy(shape);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_Exception, e.what());
|
||||
PyErr_SetString(PartExceptionOCCError, e.what());
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -1550,7 +1551,7 @@ static PyObject * getSortedClusters(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *obj;
|
||||
if (!PyArg_ParseTuple(args, "O", &obj)) {
|
||||
PyErr_SetString(PyExc_Exception, "list of edges expected");
|
||||
PyErr_SetString(PartExceptionOCCError, "list of edges expected");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1593,7 +1594,7 @@ static PyObject * sortEdges(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *obj;
|
||||
if (!PyArg_ParseTuple(args, "O", &obj)) {
|
||||
PyErr_SetString(PyExc_Exception, "list of edges expected");
|
||||
PyErr_SetString(PartExceptionOCCError, "list of edges expected");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1629,7 +1630,7 @@ static PyObject * sortEdges(PyObject *self, PyObject *args)
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PyExc_Exception, e->GetMessageString());
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1667,7 +1668,7 @@ static PyObject * cast_to_shape(PyObject *self, PyObject *args)
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_Exception, "empty shape");
|
||||
PyErr_SetString(PartExceptionOCCError, "empty shape");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user