issue #1700 replace PyExc_Exception

This commit is contained in:
Sebastian Hoogen 2014-08-29 21:12:45 +02:00 committed by wmayer
parent 1b1d8010a6
commit ed66ada1cf
21 changed files with 64 additions and 64 deletions

View File

@ -260,7 +260,7 @@ PyObject* Application::sSaveDocument(PyObject * /*self*/, PyObject *args,PyObjec
Document* doc = GetApplication().getDocument(pDoc);
if ( doc ) {
if ( doc->save() == false ) {
PyErr_Format(PyExc_Exception, "Cannot save document '%s'", pDoc);
PyErr_Format(Base::BaseExceptionFreeCADError, "Cannot save document '%s'", pDoc);
return 0L;
}
}

View File

@ -50,7 +50,7 @@ PyObject* DocumentObjectGroupPy::newObject(PyObject *args)
return object->getPyObject();
}
else {
PyErr_Format(PyExc_Exception, "Cannot create object of type '%s'", sType);
PyErr_Format(Base::BaseExceptionFreeCADError, "Cannot create object of type '%s'", sType);
return NULL;
}
}

View File

@ -202,7 +202,7 @@ PyObject* DocumentPy::addObject(PyObject *args)
else {
std::stringstream str;
str << "No document object found of type '" << sType << "'" << std::ends;
throw Py::Exception(PyExc_Exception,str.str());
throw Py::Exception(Base::BaseExceptionFreeCADError,str.str());
}
}
@ -220,7 +220,7 @@ PyObject* DocumentPy::removeObject(PyObject *args)
} else {
std::stringstream str;
str << "No document object found with name '" << sName << "'" << std::ends;
throw Py::Exception(PyExc_Exception,str.str());
throw Py::Exception(Base::BaseExceptionFreeCADError,str.str());
}
}
@ -239,7 +239,7 @@ PyObject* DocumentPy::copyObject(PyObject *args)
}
else {
std::string str("Failed to copy the object");
throw Py::Exception(PyExc_Exception,str);
throw Py::Exception(Base::BaseExceptionFreeCADError,str);
}
}
@ -256,7 +256,7 @@ PyObject* DocumentPy::moveObject(PyObject *args)
}
else {
std::string str("Failed to move the object");
throw Py::Exception(PyExc_Exception,str);
throw Py::Exception(Base::BaseExceptionFreeCADError,str);
}
}
@ -358,12 +358,12 @@ PyObject* DocumentPy::findObjects(PyObject *args)
Base::Type type = Base::Type::fromName(sType);
if (type == Base::Type::badType()) {
PyErr_Format(PyExc_Exception, "'%s' is not a valid type", sType);
PyErr_Format(Base::BaseExceptionFreeCADError, "'%s' is not a valid type", sType);
return NULL;
}
if (!type.isDerivedFrom(App::DocumentObject::getClassTypeId())) {
PyErr_Format(PyExc_Exception, "Type '%s' does not inherit from 'App::DocumentObject'", sType);
PyErr_Format(Base::BaseExceptionFreeCADError, "Type '%s' does not inherit from 'App::DocumentObject'", sType);
return NULL;
}

View File

@ -342,7 +342,7 @@ PyObject* FeaturePythonPyT<FeaturePyT>::addProperty(PyObject *args)
if (!prop) {
std::stringstream str;
str << "No property found of type '" << sType << "'" << std::ends;
throw Py::Exception(PyExc_Exception,str.str());
throw Py::Exception(Base::BaseExceptionFreeCADError,str.str());
}
return Py::new_reference_to(this);

View File

@ -572,12 +572,12 @@ PyObject *ConsoleSingleton::sPySetStatus(PyObject * /*self*/, PyObject *args, Py
else if(strcmp(pstr2,"Err") == 0)
pObs->bErr = (Bool==0)?false:true;
else
Py_Error(PyExc_Exception,"Unknown Message Type (use Log,Err,Msg or Wrn)");
Py_Error(Base::BaseExceptionFreeCADError,"Unknown Message Type (use Log,Err,Msg or Wrn)");
Py_INCREF(Py_None);
return Py_None;
} else {
Py_Error(PyExc_Exception,"Unknown Console Type");
Py_Error(Base::BaseExceptionFreeCADError,"Unknown Console Type");
}
} PY_CATCH;

View File

@ -397,7 +397,7 @@ BaseExport extern PyObject* BaseExceptionFreeCADError;
* Feature *pcFtr = _pcDocTypeStd->AddFeature(pstr);
* }catch(...) \
* { \
* Py_Error(PyExc_Exception,"Unknown C++ exception"); \
* Py_Error(Base::BaseExceptionFreeCADError,"Unknown C++ exception"); \
* }catch(FCException e) ..... // and so on.... \
* }
* \endcode

View File

@ -838,7 +838,7 @@ PyObject* Application::sRunCommand(PyObject * /*self*/, PyObject *args,PyObject
return Py_None;
}
else {
PyErr_Format(PyExc_Exception, "No such command '%s'", pName);
PyErr_Format(Base::BaseExceptionFreeCADError, "No such command '%s'", pName);
return 0;
}
}

View File

@ -106,13 +106,13 @@ PyObject* DocumentPy::setEdit(PyObject *args)
return NULL; // NULL triggers exception
App::DocumentObject * obj = getDocumentPtr()->getDocument()->getObject(psFeatStr);
if (!obj) {
PyErr_Format(PyExc_Exception, "No such object found in document: '%s'", psFeatStr);
PyErr_Format(Base::BaseExceptionFreeCADError, "No such object found in document: '%s'", psFeatStr);
return 0;
}
bool ok = getDocumentPtr()->setEdit(getDocumentPtr()->getViewProvider(obj),mod);
if (!ok) {
PyErr_Format(PyExc_Exception, "Failed to set object '%s' in edit mode", psFeatStr);
PyErr_Format(Base::BaseExceptionFreeCADError, "Failed to set object '%s' in edit mode", psFeatStr);
return 0;
}
@ -227,7 +227,7 @@ PyObject* DocumentPy::mdiViewsOfType(PyObject *args)
Base::Type type = Base::Type::fromName(sType);
if (type == Base::Type::badType()) {
PyErr_Format(PyExc_Exception, "'%s' is not a valid type", sType);
PyErr_Format(Base::BaseExceptionFreeCADError, "'%s' is not a valid type", sType);
return NULL;
}

View File

@ -79,7 +79,7 @@ PyObject* ViewProviderPythonFeaturePy::addProperty(PyObject *args)
if (!prop) {
std::stringstream str;
str << "No property found of type '" << sType << "'" << std::ends;
throw Py::Exception(PyExc_Exception,str.str());
throw Py::Exception(Base::BaseExceptionFreeCADError,str.str());
}
return Py::new_reference_to(this);

View File

@ -271,7 +271,7 @@ QWidget* setupMainWindow()
Base::Interpreter().runString(Base::ScriptFactory().ProduceScript("FreeCADGuiInit"));
}
catch (const Base::Exception& e) {
PyErr_Format(PyExc_Exception, "Error in FreeCADGuiInit.py: %s\n", e.what());
PyErr_Format(Base::BaseExceptionFreeCADError, "Error in FreeCADGuiInit.py: %s\n", e.what());
return 0;
}
init = true;

View File

@ -72,7 +72,7 @@ open(PyObject *self, PyObject *args)
}
}
else
Py_Error(PyExc_Exception,"Could not load image");
Py_Error(Base::BaseExceptionFreeCADError,"Could not load image");
// Displaying the image in a view.
// This ImageView object takes ownership of the pixel data (in 'pointImageTo') so we don't need to delete it here

View File

@ -101,7 +101,7 @@ open(PyObject *self, PyObject *args)
// extract ending
if(file.extension() == "")
Py_Error(PyExc_Exception,"no file ending");
Py_Error(Base::BaseExceptionFreeCADError,"no file ending");
if(file.hasExtension("jt"))
{
@ -140,7 +140,7 @@ open(PyObject *self, PyObject *args)
}
else
{
Py_Error(PyExc_Exception,"unknown file ending");
Py_Error(Base::BaseExceptionFreeCADError,"unknown file ending");
}
@ -165,7 +165,7 @@ insert(PyObject *self, PyObject *args)
// extract ending
if(file.extension() == "")
Py_Error(PyExc_Exception,"no file ending");
Py_Error(Base::BaseExceptionFreeCADError,"no file ending");
if(file.hasExtension("jt") )
{
@ -175,7 +175,7 @@ insert(PyObject *self, PyObject *args)
{
char szBuf[200];
snprintf(szBuf, 200, "Import called to the non-existing document '%s'", DocName);
Py_Error(PyExc_Exception,szBuf);
Py_Error(Base::BaseExceptionFreeCADError,szBuf);
}
readFile(Name,0);
@ -211,13 +211,13 @@ insert(PyObject *self, PyObject *args)
}else{
clearData();
//Py_Error(PyExc_Exception,"No Mesh in file");
//Py_Error(Base::BaseExceptionFreeCADError,"No Mesh in file");
Base::Console().Warning("No Mesh in file: %s\n",Name);
}
}
else
{
Py_Error(PyExc_Exception,"unknown file ending");
Py_Error(Base::BaseExceptionFreeCADError,"unknown file ending");
}
} PY_CATCH;

View File

@ -1252,14 +1252,14 @@ PyObject* MeshPy::collapseFacets(PyObject *args)
facets.push_back(iIdx);
}
else {
Py_Error(PyExc_Exception, "list of integers needed");
Py_Error(Base::BaseExceptionFreeCADError, "list of integers needed");
}
}
getMeshObjectPtr()->collapseFacets(facets);
}
else {
Py_Error(PyExc_Exception, "List of Integers needed");
Py_Error(Base::BaseExceptionFreeCADError, "List of Integers needed");
}
Py_Return;

View File

@ -55,17 +55,17 @@ loftOnCurve(PyObject *self, PyObject *args)
std::vector<Base::Vector3f> poly;
if (!PyList_Check(pcListObj))
Py_Error(PyExc_Exception,"List of Tuble of three or two floats needed as second parameter!");
Py_Error(Base::BaseExceptionFreeCADError,"List of Tuble of three or two floats needed as second parameter!");
int nSize = PyList_Size(pcListObj);
for (int i=0; i<nSize;++i)
{
PyObject* item = PyList_GetItem(pcListObj, i);
if (!PyTuple_Check(item))
Py_Error(PyExc_Exception,"List of Tuble of three or two floats needed as second parameter!");
Py_Error(Base::BaseExceptionFreeCADError,"List of Tuble of three or two floats needed as second parameter!");
int nTSize = PyTuple_Size(item);
if(nTSize != 2 && nTSize != 3)
Py_Error(PyExc_Exception,"List of Tuble of three or two floats needed as second parameter!");
Py_Error(Base::BaseExceptionFreeCADError,"List of Tuble of three or two floats needed as second parameter!");
Base::Vector3f vec(0,0,0);
@ -73,7 +73,7 @@ loftOnCurve(PyObject *self, PyObject *args)
{
PyObject* item2 = PyTuple_GetItem(item, l);
if (!PyFloat_Check(item2))
Py_Error(PyExc_Exception,"List of Tuble of three or two floats needed as second parameter!");
Py_Error(Base::BaseExceptionFreeCADError,"List of Tuble of three or two floats needed as second parameter!");
vec[l] = (float)PyFloat_AS_DOUBLE(item2);
}
poly.push_back(vec);

View File

@ -153,7 +153,7 @@ static PyObject * open(PyObject *self, PyObject *args)
// extract ending
if (file.extension() == "")
Py_Error(PyExc_Exception,"no file ending");
Py_Error(Base::BaseExceptionFreeCADError,"no file ending");
if (file.hasExtension("stp") || file.hasExtension("step")) {
// create new document and add Import feature
@ -186,7 +186,7 @@ static PyObject * open(PyObject *self, PyObject *args)
pcDoc->recompute();
}
catch (const Base::Exception& e) {
Py_Error(PyExc_Exception, e.what());
Py_Error(Base::BaseExceptionFreeCADError, e.what());
}
}
} PY_CATCH_OCC;
@ -208,7 +208,7 @@ static PyObject * insert(PyObject *self, PyObject *args)
// extract ending
if (file.extension() == "")
Py_Error(PyExc_Exception,"no file ending");
Py_Error(Base::BaseExceptionFreeCADError,"no file ending");
App::Document *pcDoc = App::GetApplication().getDocument(DocName);
if (!pcDoc) {
pcDoc = App::GetApplication().newDocument(DocName);
@ -241,7 +241,7 @@ static PyObject * insert(PyObject *self, PyObject *args)
pcDoc->recompute();
}
catch (const Base::Exception& e) {
Py_Error(PyExc_Exception, e.what());
Py_Error(Base::BaseExceptionFreeCADError, e.what());
}
}
} PY_CATCH_OCC;

View File

@ -1763,7 +1763,7 @@ Py::String TopoShapePy::getShapeType(void) const
{
TopoDS_Shape sh = getTopoShapePtr()->_Shape;
if (sh.IsNull())
throw Py::Exception(PyExc_Exception, "cannot determine type of null shape");
throw Py::Exception(Base::BaseExceptionFreeCADError, "cannot determine type of null shape");
TopAbs_ShapeEnum type = sh.ShapeType();
std::string name;
switch (type)
@ -1804,7 +1804,7 @@ Py::String TopoShapePy::getOrientation(void) const
{
TopoDS_Shape sh = getTopoShapePtr()->_Shape;
if (sh.IsNull())
throw Py::Exception(PyExc_Exception, "cannot determine orientation of null shape");
throw Py::Exception(Base::BaseExceptionFreeCADError, "cannot determine orientation of null shape");
TopAbs_Orientation type = sh.Orientation();
std::string name;
switch (type)
@ -1830,7 +1830,7 @@ void TopoShapePy::setOrientation(Py::String arg)
{
TopoDS_Shape& sh = getTopoShapePtr()->_Shape;
if (sh.IsNull())
throw Py::Exception(PyExc_Exception, "cannot determine orientation of null shape");
throw Py::Exception(Base::BaseExceptionFreeCADError, "cannot determine orientation of null shape");
std::string name = (std::string)arg;
TopAbs_Orientation type;
if (name == "Forward") {

View File

@ -62,7 +62,7 @@ open(PyObject *self, PyObject *args)
// extract ending
if (file.extension() == "")
Py_Error(PyExc_Exception,"no file ending");
Py_Error(Base::BaseExceptionFreeCADError,"no file ending");
if (file.hasExtension("asc")) {
// create new document and add Import feature
@ -90,7 +90,7 @@ open(PyObject *self, PyObject *args)
}
#endif
else {
Py_Error(PyExc_Exception,"unknown file ending");
Py_Error(Base::BaseExceptionFreeCADError,"unknown file ending");
}
} PY_CATCH;
@ -111,7 +111,7 @@ insert(PyObject *self, PyObject *args)
// extract ending
if (file.extension() == "")
Py_Error(PyExc_Exception,"no file ending");
Py_Error(Base::BaseExceptionFreeCADError,"no file ending");
if (file.hasExtension("asc")) {
// add Import feature
@ -145,7 +145,7 @@ insert(PyObject *self, PyObject *args)
}
#endif
else {
Py_Error(PyExc_Exception,"unknown file ending");
Py_Error(Base::BaseExceptionFreeCADError,"unknown file ending");
}
} PY_CATCH;

View File

@ -185,7 +185,7 @@ writeCameraFile(PyObject *self, PyObject *args)
for(int i=0;i<4;i++) {
// check the right size of the Tuple of floats
if(PyTuple_GET_SIZE(Arg[i]) != 3)
Py_Error(PyExc_Exception,"Wrong parameter format, four Tuple of three floats needed!");
Py_Error(Base::BaseExceptionFreeCADError,"Wrong parameter format, four Tuple of three floats needed!");
// go through the Tuple of floats
for(int l=0;l<3;l++) {
@ -198,7 +198,7 @@ writeCameraFile(PyObject *self, PyObject *args)
else if (PyInt_Check(temp))
vecs[i][l] = (double) PyInt_AsLong(temp);
else
Py_Error(PyExc_Exception,"Wrong parameter format, four Tuple of three floats needed!");
Py_Error(Base::BaseExceptionFreeCADError,"Wrong parameter format, four Tuple of three floats needed!");
}
}

View File

@ -112,7 +112,7 @@ PyObject* TrajectoryPy::insertWaypoints(PyObject * args)
return new TrajectoryPy(new Robot::Trajectory(*getTrajectoryPtr()));
}
Py_Error(PyExc_Exception, "Wrong parameters - waypoint or placement expected");
Py_Error(Base::BaseExceptionFreeCADError, "Wrong parameters - waypoint or placement expected");
}

View File

@ -61,7 +61,7 @@ static PyObject * open(PyObject *self, PyObject *args)
// extract ending
if (file.extension() == "")
Py_Error(PyExc_Exception,"no file ending");
Py_Error(Base::BaseExceptionFreeCADError,"no file ending");
//if (file.hasExtension("igs") || file.hasExtension("iges")) {
// // create new document and add Import feature
@ -71,7 +71,7 @@ static PyObject * open(PyObject *self, PyObject *args)
// pcDoc->recompute();
//}
// else {
Py_Error(PyExc_Exception,"unknown file ending");
Py_Error(Base::BaseExceptionFreeCADError,"unknown file ending");
//}
Py_Return;
@ -91,7 +91,7 @@ static PyObject * insert(PyObject *self, PyObject *args)
// extract ending
if (file.extension() == "")
Py_Error(PyExc_Exception,"no file ending");
Py_Error(Base::BaseExceptionFreeCADError,"no file ending");
App::Document *pcDoc = App::GetApplication().getDocument(DocName);
if (!pcDoc) {
pcDoc = App::GetApplication().newDocument(DocName);
@ -105,7 +105,7 @@ static PyObject * insert(PyObject *self, PyObject *args)
pcDoc->recompute();
}
else {
Py_Error(PyExc_Exception,"unknown file ending");
Py_Error(Base::BaseExceptionFreeCADError,"unknown file ending");
}
} PY_CATCH;

View File

@ -473,7 +473,7 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject
str += e.what();
str += ")";
e.ReportException();
PyErr_SetString(PyExc_Exception,str.c_str());
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());
return NULL;
}
catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
@ -485,7 +485,7 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject
str += e.what();
str += ")\\n";
Base::Console().Error(str.c_str());
PyErr_SetString(PyExc_Exception,str.c_str());
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());
return NULL;
}
catch(const Py::Exception&)
@ -496,7 +496,7 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject
catch(const char* e) // catch simple string exceptions
{
Base::Console().Error(e);
PyErr_SetString(PyExc_Exception,e);
PyErr_SetString(Base::BaseExceptionFreeCADError,e);
return NULL;
}
// in debug not all exceptions will be catched to get the attention of the developer!
@ -508,12 +508,12 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject
str += e.what();
str += ")";
Base::Console().Error(str.c_str());
PyErr_SetString(PyExc_Exception,str.c_str());
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());
return NULL;
}
catch(...) // catch the rest!
{
PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
PyErr_SetString(Base::BaseExceptionFreeCADError,"Unknown C++ exception");
return NULL;
}
#endif
@ -537,7 +537,7 @@ PyObject * @self.export.Name@::staticCallback_get@i.Name@ (PyObject *self, void
// The exception text is already set
return NULL;
} catch (...) {
PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute '@i.Name@' of object '@self.export.Twin@'");
PyErr_SetString(Base::BaseExceptionFreeCADError, "Unknown exception while reading attribute '@i.Name@' of object '@self.export.Twin@'");
return NULL;
}
}
@ -576,7 +576,7 @@ int @self.export.Name@::staticCallback_set@i.Name@ (PyObject *self, PyObject *va
// The exception text is already set
return -1;
} catch (...) {
PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute '@i.Name@' of object '@self.export.Twin@'");
PyErr_SetString(Base::BaseExceptionFreeCADError, "Unknown exception while writing attribute '@i.Name@' of object '@self.export.Twin@'");
return -1;
}
}
@ -658,7 +658,7 @@ PyObject *@self.export.Name@::_getattr(char *attr) // __getattr__ function: n
str += e.what();
str += ")";
e.ReportException();
PyErr_SetString(PyExc_Exception,str.c_str());
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());
return NULL;
}
catch(const std::exception& e) // catch other c++ exceptions
@ -668,7 +668,7 @@ PyObject *@self.export.Name@::_getattr(char *attr) // __getattr__ function: n
str += e.what();
str += ")";
Base::Console().Error(str.c_str());
PyErr_SetString(PyExc_Exception,str.c_str());
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());
return NULL;
}
catch(const Py::Exception&)
@ -678,7 +678,7 @@ PyObject *@self.export.Name@::_getattr(char *attr) // __getattr__ function: n
}
catch(...) // catch the rest!
{
PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
PyErr_SetString(Base::BaseExceptionFreeCADError,"Unknown C++ exception");
return NULL;
}
#else // DONT_CATCH_CXX_EXCEPTIONS
@ -689,7 +689,7 @@ PyObject *@self.export.Name@::_getattr(char *attr) // __getattr__ function: n
str += e.what();
str += ")";
e.ReportException();
PyErr_SetString(PyExc_Exception,str.c_str());
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());
return NULL;
}
catch(const Py::Exception&)
@ -726,7 +726,7 @@ int @self.export.Name@::_setattr(char *attr, PyObject *value) // __setattr__ fu
str += e.what();
str += ")";
e.ReportException();
PyErr_SetString(PyExc_Exception,str.c_str());
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());
return -1;
}
catch(const std::exception& e) // catch other c++ exceptions
@ -736,7 +736,7 @@ int @self.export.Name@::_setattr(char *attr, PyObject *value) // __setattr__ fu
str += e.what();
str += ")";
Base::Console().Error(str.c_str());
PyErr_SetString(PyExc_Exception,str.c_str());
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());
return -1;
}
catch(const Py::Exception&)
@ -746,7 +746,7 @@ int @self.export.Name@::_setattr(char *attr, PyObject *value) // __setattr__ fu
}
catch(...) // catch the rest!
{
PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
PyErr_SetString(Base::BaseExceptionFreeCADError,"Unknown C++ exception");
return -1;
}
#else // DONT_CATCH_CXX_EXCEPTIONS
@ -757,7 +757,7 @@ int @self.export.Name@::_setattr(char *attr, PyObject *value) // __setattr__ fu
str += e.what();
str += ")";
e.ReportException();
PyErr_SetString(PyExc_Exception,str.c_str());
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());
return -1;
}
catch(const Py::Exception&)