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:
Sebastian Hoogen
2014-08-19 11:18:19 +02:00
committed by wmayer
parent 6cd1feb44f
commit af50cbf964
69 changed files with 749 additions and 501 deletions

View File

@@ -64,6 +64,7 @@
#include "PlanePy.h"
#include "BSplineCurvePy.h"
#include "OCCError.h"
#include "TopoShape.h"
#include "TopoShapePy.h"
#include "TopoShapeEdgePy.h"
@@ -108,11 +109,11 @@ PyObject* GeometryCurvePy::toShape(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;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
@@ -122,7 +123,7 @@ PyObject* GeometryCurvePy::discretize(PyObject *args, PyObject *kwds)
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
if (c.IsNull()) {
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
@@ -185,7 +186,7 @@ PyObject* GeometryCurvePy::discretize(PyObject *args, PyObject *kwds)
return Py::new_reference_to(points);
}
else {
PyErr_SetString(PyExc_Exception, "Discretization of curve failed");
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
return 0;
}
}
@@ -207,7 +208,7 @@ PyObject* GeometryCurvePy::discretize(PyObject *args, PyObject *kwds)
return Py::new_reference_to(points);
}
else {
PyErr_SetString(PyExc_Exception, "Discretization of curve failed");
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
return 0;
}
}
@@ -231,7 +232,7 @@ PyObject* GeometryCurvePy::discretize(PyObject *args, PyObject *kwds)
return Py::new_reference_to(points);
}
else {
PyErr_SetString(PyExc_Exception, "Discretization of curve failed");
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
return 0;
}
}
@@ -253,7 +254,7 @@ PyObject* GeometryCurvePy::discretize(PyObject *args, PyObject *kwds)
return Py::new_reference_to(points);
}
else {
PyErr_SetString(PyExc_Exception, "Discretization of curve failed");
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
return 0;
}
}
@@ -275,17 +276,17 @@ PyObject* GeometryCurvePy::discretize(PyObject *args, PyObject *kwds)
return Py::new_reference_to(points);
}
else {
PyErr_SetString(PyExc_Exception, "Discretization of curve failed");
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
return 0;
}
}
}
catch (const Base::Exception& e) {
PyErr_SetString(PyExc_Exception, e.what());
PyErr_SetString(PartExceptionOCCError, e.what());
return 0;
}
PyErr_SetString(PyExc_Exception,"Wrong arguments");
PyErr_SetString(PartExceptionOCCError,"Wrong arguments");
return 0;
}
@@ -307,11 +308,11 @@ PyObject* GeometryCurvePy::length(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;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
@@ -330,11 +331,11 @@ PyObject* GeometryCurvePy::value(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;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
@@ -360,11 +361,11 @@ PyObject* GeometryCurvePy::tangent(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;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
@@ -386,11 +387,11 @@ PyObject* GeometryCurvePy::parameter(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;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
@@ -406,7 +407,7 @@ PyObject* GeometryCurvePy::makeRuledSurface(PyObject *args)
Handle_Geom_Curve aCrv2 = Handle_Geom_Curve::DownCast(c->getGeometryPtr()->handle());
Handle_Geom_Surface aSurf = GeomFill::Surface (aCrv1, aCrv2);
if (aSurf.IsNull()) {
PyErr_SetString(PyExc_Exception, "Failed to create ruled surface");
PyErr_SetString(PartExceptionOCCError, "Failed to create ruled surface");
return 0;
}
// check the result surface type
@@ -428,11 +429,11 @@ PyObject* GeometryCurvePy::makeRuledSurface(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;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
@@ -466,7 +467,7 @@ PyObject* GeometryCurvePy::intersect2d(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;
}
}
@@ -491,11 +492,11 @@ PyObject* GeometryCurvePy::toBSpline(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;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
@@ -545,7 +546,7 @@ PyObject* GeometryCurvePy::approximateBSpline(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;
}
}