Skip to content

Commit

Permalink
use specialized Python exception classes
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Apr 28, 2017
1 parent 1673ab8 commit 18f723c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/Mod/Import/App/AppImportPy.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Part/App/Geom2d/Curve2dPyImp.cpp
Expand Up @@ -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;
}
14 changes: 7 additions & 7 deletions src/Mod/Part/App/GeometryCurvePyImp.cpp
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
10 changes: 5 additions & 5 deletions src/Mod/Part/App/GeometrySurfacePyImp.cpp
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

0 comments on commit 18f723c

Please sign in to comment.