use specialized Python exception classes

This commit is contained in:
wmayer
2017-04-28 19:33:51 +02:00
parent fb7094bf31
commit 800526836a
4 changed files with 18 additions and 18 deletions

View File

@@ -350,7 +350,7 @@ static PyObject * importAssembly(PyObject *self, PyObject *args)
aReader.SetNameMode(true);
aReader.SetLayerMode(true);
if (aReader.ReadFile((Standard_CString)(name8bit.c_str())) != IFSelect_RetDone) {
PyErr_SetString(PyExc_Exception, "cannot read STEP file");
PyErr_SetString(PyExc_IOError, "cannot read STEP file");
return 0;
}
@@ -379,7 +379,7 @@ static PyObject * importAssembly(PyObject *self, PyObject *args)
aReader.SetNameMode(true);
aReader.SetLayerMode(true);
if (aReader.ReadFile((Standard_CString)(name8bit.c_str())) != IFSelect_RetDone) {
PyErr_SetString(PyExc_Exception, "cannot read IGES file");
PyErr_SetString(PyExc_IOError, "cannot read IGES file");
return 0;
}
@@ -400,7 +400,7 @@ static PyObject * importAssembly(PyObject *self, PyObject *args)
}
}
else {
PyErr_SetString(PyExc_Exception, "no supported file format");
PyErr_SetString(PyExc_RuntimeError, "no supported file format");
return 0;
}
@@ -411,7 +411,7 @@ static PyObject * importAssembly(PyObject *self, PyObject *args)
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
PyErr_SetString(PyExc_RuntimeError, e->GetMessageString());
return 0;
}
PY_CATCH

View File

@@ -912,10 +912,10 @@ PyObject* Curve2dPy::intersectCC(PyObject *args)
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
PyErr_SetString(PyExc_RuntimeError, e->GetMessageString());
return 0;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PyExc_TypeError, "Geometry is not a curve");
return 0;
}

View File

@@ -754,7 +754,7 @@ PyObject* GeometryCurvePy::intersectCS(PyObject *args)
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast(static_cast<GeometryPy*>(p)->getGeometryPtr()->handle());
GeomAPI_IntCS intersector(curve, surf);
if (!intersector.IsDone()) {
PyErr_SetString(PyExc_Exception, "Intersection of curve and surface failed");
PyErr_SetString(PyExc_RuntimeError, "Intersection of curve and surface failed");
return 0;
}
@@ -777,11 +777,11 @@ PyObject* GeometryCurvePy::intersectCS(PyObject *args)
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
PyErr_SetString(PyExc_RuntimeError, e->GetMessageString());
return 0;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PyExc_TypeError, "Geometry is not a curve");
return 0;
}
@@ -815,11 +815,11 @@ PyObject* GeometryCurvePy::intersectCC(PyObject *args)
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
PyErr_SetString(PyExc_RuntimeError, e->GetMessageString());
return 0;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PyExc_TypeError, "Geometry is not a curve");
return 0;
}
@@ -846,10 +846,10 @@ PyObject* GeometryCurvePy::intersect(PyObject *args)
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
PyErr_SetString(PyExc_RuntimeError, e->GetMessageString());
return 0;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
PyErr_SetString(PyExc_TypeError, "Geometry is not a curve");
return 0;
}

View File

@@ -536,7 +536,7 @@ PyObject* GeometrySurfacePy::intersectSS(PyObject *args)
Handle(Geom_Surface) surf2 = Handle(Geom_Surface)::DownCast(static_cast<GeometryPy*>(p)->getGeometryPtr()->handle());
GeomAPI_IntSS intersector(surf1, surf2, prec);
if (!intersector.IsDone()) {
PyErr_SetString(PyExc_Exception, "Intersection of surfaces failed");
PyErr_SetString(PyExc_RuntimeError, "Intersection of surfaces failed");
return 0;
}
@@ -551,11 +551,11 @@ PyObject* GeometrySurfacePy::intersectSS(PyObject *args)
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
PyErr_SetString(PyExc_RuntimeError, e->GetMessageString());
return 0;
}
PyErr_SetString(PyExc_Exception, "intersectSS(): Geometry is not a surface");
PyErr_SetString(PyExc_TypeError, "intersectSS(): Geometry is not a surface");
return 0;
}
@@ -588,10 +588,10 @@ PyObject* GeometrySurfacePy::intersect(PyObject *args)
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
PyErr_SetString(PyExc_RuntimeError, e->GetMessageString());
return 0;
}
PyErr_SetString(PyExc_Exception, "intersect(): Geometry is not a surface");
PyErr_SetString(PyExc_TypeError, "intersect(): Geometry is not a surface");
return 0;
}