Skip to content

Commit

Permalink
Fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan authored and wwmayer committed Nov 18, 2016
1 parent 6f424c1 commit 804dc1c
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/Mod/TechDraw/App/AppTechDrawPy.cpp
Expand Up @@ -120,9 +120,7 @@ class Module : public Py::ExtensionModule<Module>
PyObject *pcObj;
PyObject *inclBig = Py_True;
if (!PyArg_ParseTuple(args.ptr(), "O!|O", &(PyList_Type), &pcObj, &inclBig)) {
std::string error = std::string("expected List, not ");
error += pcObj->ob_type->tp_name;
throw Base::TypeError(error);
throw Py::Exception("expected (listofedges,boolean");
}

std::vector<TopoDS_Edge> edgeList;
Expand Down Expand Up @@ -179,9 +177,7 @@ class Module : public Py::ExtensionModule<Module>
{
PyObject *pcObj;
if (!PyArg_ParseTuple(args.ptr(), "O!", &(PyList_Type), &pcObj)) {
std::string error = std::string("expected List, not ");
error += pcObj->ob_type->tp_name;
throw Base::TypeError(error);
throw Py::Exception("expected (listofedges)");
}

std::vector<TopoDS_Edge> edgeList;
Expand Down Expand Up @@ -238,19 +234,15 @@ class Module : public Py::ExtensionModule<Module>
if (!PyArg_ParseTuple(args.ptr(), "OdO", &pcObjShape,
&scale,
&pcObjDir)) {
throw Py::Exception();
throw Py::Exception("expected (shape,scale,direction");
}

if (!PyObject_TypeCheck(pcObjShape, &(TopoShapePy::Type))) {
std::string error = std::string("type(1) must be 'Shape', not ");
error += pcObjShape->ob_type->tp_name;
throw Base::TypeError(error);
throw Py::TypeError("expected arg1 to be 'Shape'");
}

if (!PyObject_TypeCheck(pcObjDir, &(Base::VectorPy::Type))) {
std::string error = std::string("type(3) must be 'Vector', not ");
error += pcObjDir->ob_type->tp_name;
throw Py::TypeError(error);
throw Py::TypeError("expected arg3 to be 'Vector'");
}

TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObjShape);
Expand Down

0 comments on commit 804dc1c

Please sign in to comment.