Base: rename BaseExceptionFreeCADError to PyExc_FC_GeneralError

This commit is contained in:
wmayer
2022-03-17 14:45:48 +01:00
parent 1f12dca2b4
commit e4d1ed8366
29 changed files with 114 additions and 114 deletions

View File

@@ -165,7 +165,7 @@ Base::ConsoleObserverFile *Application::_pConsoleObserverFile = nullptr;
AppExport std::map<std::string,std::string> Application::mConfig;
// Custom Python exception types
BaseExport extern PyObject* Base::BaseExceptionFreeCADError;
BaseExport extern PyObject* Base::PyExc_FC_GeneralError;
BaseExport extern PyObject* Base::PyExc_FC_FreeCADAbort;
BaseExport extern PyObject* Base::PyExc_FC_XMLBaseException;
BaseExport extern PyObject* Base::PyExc_FC_XMLParseException;
@@ -361,9 +361,9 @@ void Application::setupPythonException(PyObject* module)
{
// Define cusom Python exception types
//
Base::BaseExceptionFreeCADError = PyErr_NewException("Base.FreeCADError", PyExc_RuntimeError, nullptr);
Py_INCREF(Base::BaseExceptionFreeCADError);
PyModule_AddObject(module, "FreeCADError", Base::BaseExceptionFreeCADError);
Base::PyExc_FC_GeneralError = PyErr_NewException("Base.FreeCADError", PyExc_RuntimeError, nullptr);
Py_INCREF(Base::PyExc_FC_GeneralError);
PyModule_AddObject(module, "FreeCADError", Base::PyExc_FC_GeneralError);
Base::PyExc_FC_FreeCADAbort = PyErr_NewException("Base.FreeCADAbort", PyExc_BaseException, nullptr);
Py_INCREF(Base::PyExc_FC_FreeCADAbort);
@@ -385,23 +385,23 @@ void Application::setupPythonException(PyObject* module)
Py_INCREF(Base::PyExc_FC_UnknownProgramOption);
PyModule_AddObject(module, "UnknownProgramOption", Base::PyExc_FC_UnknownProgramOption);
Base::PyExc_FC_BadFormatError = PyErr_NewException("Base.BadFormatError", PyExc_Exception, nullptr);
Base::PyExc_FC_BadFormatError = PyErr_NewException("Base.BadFormatError", Base::PyExc_FC_GeneralError, nullptr);
Py_INCREF(Base::PyExc_FC_BadFormatError);
PyModule_AddObject(module, "BadFormatError", Base::PyExc_FC_BadFormatError);
Base::PyExc_FC_BadGraphError = PyErr_NewException("Base.BadGraphError", PyExc_Exception, nullptr);
Base::PyExc_FC_BadGraphError = PyErr_NewException("Base.BadGraphError", Base::PyExc_FC_GeneralError, nullptr);
Py_INCREF(Base::PyExc_FC_BadGraphError);
PyModule_AddObject(module, "BadGraphError", Base::PyExc_FC_BadGraphError);
Base::PyExc_FC_ExpressionError = PyErr_NewException("Base.ExpressionError", PyExc_Exception, nullptr);
Base::PyExc_FC_ExpressionError = PyErr_NewException("Base.ExpressionError", Base::PyExc_FC_GeneralError, nullptr);
Py_INCREF(Base::PyExc_FC_ExpressionError);
PyModule_AddObject(module, "ExpressionError", Base::PyExc_FC_ExpressionError);
Base::PyExc_FC_ParserError = PyErr_NewException("Base.ParserError", PyExc_Exception, nullptr);
Base::PyExc_FC_ParserError = PyErr_NewException("Base.ParserError", Base::PyExc_FC_GeneralError, nullptr);
Py_INCREF(Base::PyExc_FC_ParserError);
PyModule_AddObject(module, "ParserError", Base::PyExc_FC_ParserError);
Base::PyExc_FC_CADKernelError = PyErr_NewException("Base.CADKernelError", PyExc_Exception, nullptr);
Base::PyExc_FC_CADKernelError = PyErr_NewException("Base.CADKernelError", Base::PyExc_FC_GeneralError, nullptr);
Py_INCREF(Base::PyExc_FC_CADKernelError);
PyModule_AddObject(module, "CADKernelError", Base::PyExc_FC_CADKernelError);
}

View File

@@ -332,7 +332,7 @@ PyObject* Application::sSaveDocument(PyObject * /*self*/, PyObject *args)
Document* doc = GetApplication().getDocument(pDoc);
if ( doc ) {
if ( doc->save() == false ) {
PyErr_Format(Base::BaseExceptionFreeCADError, "Cannot save document '%s'", pDoc);
PyErr_Format(Base::PyExc_FC_GeneralError, "Cannot save document '%s'", pDoc);
return nullptr;
}
}
@@ -790,7 +790,7 @@ PyObject *Application::sSetLogLevel(PyObject * /*self*/, PyObject *args)
else if(strcmp(pstr,"Default") == 0)
l = FC_LOGLEVEL_DEFAULT;
else {
Py_Error(Base::BaseExceptionFreeCADError,
Py_Error(PyExc_ValueError,
"Unknown Log Level (use 'Default', 'Error', 'Warning', 'Message', 'Log', 'Trace' or an integer)");
return nullptr;
}

View File

@@ -63,22 +63,22 @@ PyObject* GroupExtensionPy::addObject(PyObject *args)
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot add an invalid object");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot add an invalid object");
return nullptr;
}
if (docObj->getDocumentObjectPtr()->getDocument() != getGroupExtensionPtr()->getExtendedObject()->getDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot add an object from another document to this group");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot add an object from another document to this group");
return nullptr;
}
if (docObj->getDocumentObjectPtr() == this->getGroupExtensionPtr()->getExtendedObject()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot add a group object to itself");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot add a group object to itself");
return nullptr;
}
if (docObj->getDocumentObjectPtr()->hasExtension(GroupExtension::getExtensionClassTypeId())) {
App::GroupExtension* docGrp = docObj->getDocumentObjectPtr()->getExtensionByType<GroupExtension>();
if (docGrp->hasObject(getGroupExtensionPtr()->getExtendedObject())) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot add a group object to a child group");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot add a group object to a child group");
return nullptr;
}
}
@@ -175,11 +175,11 @@ PyObject* GroupExtensionPy::removeObject(PyObject *args)
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot remove an invalid object");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot remove an invalid object");
return nullptr;
}
if (docObj->getDocumentObjectPtr()->getDocument() != getGroupExtensionPtr()->getExtendedObject()->getDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot remove an object from another document from this group");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot remove an object from another document from this group");
return nullptr;
}
@@ -263,11 +263,11 @@ PyObject* GroupExtensionPy::hasObject(PyObject *args)
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot check an invalid object");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check an invalid object");
return nullptr;
}
if (docObj->getDocumentObjectPtr()->getDocument() != getGroupExtensionPtr()->getExtendedObject()->getDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot check an object from another document with this group");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check an object from another document with this group");
return nullptr;
}
if (recursivePy) {

View File

@@ -90,7 +90,7 @@ int MetadataPy::PyInit(PyObject* args, PyObject* /*kwd*/)
return -1;
}
catch (...) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Failed to create Metadata object");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Failed to create Metadata object");
return -1;
}
}
@@ -104,7 +104,7 @@ int MetadataPy::PyInit(PyObject* args, PyObject* /*kwd*/)
return 0;
}
PyErr_SetString(Base::BaseExceptionFreeCADError, "metadata object or path to metadata file expected");
PyErr_SetString(Base::PyExc_FC_GeneralError, "metadata object or path to metadata file expected");
return -1;
}

View File

@@ -324,7 +324,7 @@ PyObject* BoundBoxPy::getIntersectionPoint(PyObject *args)
return new VectorPy(point);
}
else {
PyErr_SetString(Base::BaseExceptionFreeCADError, "No intersection");
PyErr_SetString(Base::PyExc_FC_GeneralError, "No intersection");
return nullptr;
}
}

View File

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

View File

@@ -147,14 +147,14 @@ void Exception::setPyObject( PyObject * pydict)
PyObject * Exception::getPyExceptionType() const
{
return BaseExceptionFreeCADError;
return PyExc_FC_GeneralError;
}
void Exception::setPyException() const
{
PyObject* exc = getPyExceptionType();
if (!exc) {
exc = BaseExceptionFreeCADError;
exc = PyExc_FC_GeneralError;
}
PyErr_SetString(exc, what());

View File

@@ -633,7 +633,7 @@ PyObject* MatrixPy::invert(PyObject * args)
if (fabs(getMatrixPtr()->determinant()) > DBL_EPSILON)
getMatrixPtr()->inverseGauss();
else {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot invert singular matrix");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot invert singular matrix");
return nullptr;
}
}
@@ -654,7 +654,7 @@ PyObject* MatrixPy::inverse(PyObject * args)
return new MatrixPy(m);
}
else {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot invert singular matrix");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot invert singular matrix");
return nullptr;
}
}

View File

@@ -36,7 +36,7 @@
using namespace Base;
PyObject* Base::BaseExceptionFreeCADError = nullptr;
PyObject* Base::PyExc_FC_GeneralError = nullptr;
PyObject* Base::PyExc_FC_FreeCADAbort = nullptr;
PyObject* Base::PyExc_FC_XMLBaseException = nullptr;
PyObject* Base::PyExc_FC_XMLParseException = nullptr;

View File

@@ -410,9 +410,9 @@ static PyObject * s##DFUNC (PyObject *self, PyObject *args, PyObject * /*kwd*/){
*/
#define PYMETHODEDEF(FUNC) {"" #FUNC "",(PyCFunction) s##FUNC,Py_NEWARGS},
BaseExport extern PyObject* BaseExceptionFreeCADError;
#define PY_FCERROR (Base::BaseExceptionFreeCADError ? \
BaseExceptionFreeCADError : PyExc_RuntimeError)
BaseExport extern PyObject* PyExc_FC_GeneralError;
#define PY_FCERROR (Base::PyExc_FC_GeneralError ? \
PyExc_FC_GeneralError : PyExc_RuntimeError)
BaseExport extern PyObject* PyExc_FC_FreeCADAbort;
BaseExport extern PyObject* PyExc_FC_XMLBaseException;
@@ -433,14 +433,14 @@ BaseExport extern PyObject* PyExc_FC_CADKernelError;
* PYFUNCIMP_D(DocTypeStdPy,AddFeature)
* {
* char *pstr;
* if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
* return NULL; // NULL triggers exception
* if (!PyArg_ParseTuple(args, "s", &pstr))
* return nullptr;
*
* try {
* Feature *pcFtr = _pcDocTypeStd->AddFeature(pstr);
* }catch(...) \
* { \
* Py_Error(Base::BaseExceptionFreeCADError,"Unknown C++ exception"); \
* Py_Error(Base::PyExc_FC_GeneralError,"Unknown C++ exception"); \
* }catch(FCException e) ..... // and so on.... \
* }
* \endcode
@@ -449,8 +449,8 @@ BaseExport extern PyObject* PyExc_FC_CADKernelError;
* PYFUNCIMP_D(DocTypeStdPy,AddFeature)
* {
* char *pstr;
* if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
* return NULL; // NULL triggers exception
* if (!PyArg_ParseTuple(args, "s", &pstr))
* return nullptr;
*
* PY_TRY {
* Feature *pcFtr = _pcDocTypeStd->AddFeature(pstr);
@@ -469,12 +469,12 @@ BaseExport extern PyObject* PyExc_FC_CADKernelError;
{ \
auto pye = e.getPyExceptionType(); \
if(!pye) \
pye = Base::BaseExceptionFreeCADError; \
pye = Base::PyExc_FC_GeneralError; \
_Py_ErrorObj(R,pye,e.getPyObject()); \
} \
catch(const std::exception &e) \
{ \
_Py_Error(R,Base::BaseExceptionFreeCADError,e.what()); \
_Py_Error(R,Base::PyExc_FC_GeneralError, e.what()); \
} \
catch(const Py::Exception&) \
{ \
@@ -487,7 +487,7 @@ BaseExport extern PyObject* PyExc_FC_CADKernelError;
__PY_CATCH(R) \
catch(...) \
{ \
_Py_Error(R,Base::BaseExceptionFreeCADError,"Unknown C++ exception"); \
_Py_Error(R,Base::PyExc_FC_GeneralError,"Unknown C++ exception"); \
}
#else

View File

@@ -187,7 +187,7 @@ int RotationPy::PyInit(PyObject* args, PyObject* kwds)
str += "FreeCAD exception thrown (";
str += e.what();
str += ")";
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());
PyErr_SetString(Base::PyExc_FC_GeneralError,str.c_str());
return -1;
}

View File

@@ -464,7 +464,7 @@ PyObject* VectorPy::normalize(PyObject *args)
return nullptr;
VectorPy::PointerType ptr = reinterpret_cast<VectorPy::PointerType>(_pcTwinPointer);
if (ptr->Length() < Vector3d::epsilon()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot normalize null vector");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot normalize null vector");
return nullptr;
}

View File

@@ -1007,7 +1007,7 @@ PyObject* Application::sActivateWorkbenchHandler(PyObject * /*self*/, PyObject *
catch (const Base::Exception& e) {
std::stringstream err;
err << psKey << ": " << e.what();
PyErr_SetString(Base::BaseExceptionFreeCADError, err.str().c_str());
PyErr_SetString(Base::PyExc_FC_GeneralError, err.str().c_str());
return nullptr;
}
catch (const XERCES_CPP_NAMESPACE_QUALIFIER TranscodingException& e) {
@@ -1025,7 +1025,7 @@ PyObject* Application::sActivateWorkbenchHandler(PyObject * /*self*/, PyObject *
catch (...) {
std::stringstream err;
err << "Unknown C++ exception raised in activateWorkbench('" << psKey << "')";
PyErr_SetString(Base::BaseExceptionFreeCADError, err.str().c_str());
PyErr_SetString(Base::PyExc_FC_GeneralError, err.str().c_str());
return nullptr;
}
}
@@ -1240,7 +1240,7 @@ PyObject* Application::sAddIcon(PyObject * /*self*/, PyObject *args)
PyBuffer_Release(&content);
if (icon.isNull()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Invalid icon added to application");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Invalid icon added to application");
return nullptr;
}
@@ -1357,7 +1357,7 @@ PyObject* Application::sAddCommand(PyObject * /*self*/, PyObject *args)
return nullptr;
}
catch (...) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Unknown C++ exception raised in Application::sAddCommand()");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Unknown C++ exception raised in Application::sAddCommand()");
return nullptr;
}
@@ -1380,7 +1380,7 @@ PyObject* Application::sRunCommand(PyObject * /*self*/, PyObject *args)
Py_Return;
}
else {
PyErr_Format(Base::BaseExceptionFreeCADError, "No such command '%s'", pName);
PyErr_Format(Base::PyExc_FC_GeneralError, "No such command '%s'", pName);
return nullptr;
}
}

View File

@@ -140,7 +140,7 @@ PyObject* CommandPy::run(PyObject *args)
Py_Return;
}
else {
PyErr_Format(Base::BaseExceptionFreeCADError, "No such command");
PyErr_Format(Base::PyExc_FC_GeneralError, "No such command");
return nullptr;
}
}
@@ -158,7 +158,7 @@ PyObject* CommandPy::isActive(PyObject *args)
PY_CATCH;
}
else {
PyErr_Format(Base::BaseExceptionFreeCADError, "No such command");
PyErr_Format(Base::PyExc_FC_GeneralError, "No such command");
return nullptr;
}
}
@@ -174,7 +174,7 @@ PyObject* CommandPy::getShortcut(PyObject *args)
return str;
}
else {
PyErr_Format(Base::BaseExceptionFreeCADError, "No such command");
PyErr_Format(Base::PyExc_FC_GeneralError, "No such command");
return nullptr;
}
}
@@ -216,7 +216,7 @@ PyObject* CommandPy::setShortcut(PyObject *args)
}
}
else {
PyErr_Format(Base::BaseExceptionFreeCADError, "No such command");
PyErr_Format(Base::PyExc_FC_GeneralError, "No such command");
return nullptr;
}
}
@@ -248,7 +248,7 @@ PyObject* CommandPy::resetShortcut(PyObject *args)
}
} else {
PyErr_Format(Base::BaseExceptionFreeCADError, "No such command");
PyErr_Format(Base::PyExc_FC_GeneralError, "No such command");
return nullptr;
}
}
@@ -286,7 +286,7 @@ PyObject* CommandPy::getInfo(PyObject *args)
return pyList;
}
else {
PyErr_Format(Base::BaseExceptionFreeCADError, "No such command");
PyErr_Format(Base::PyExc_FC_GeneralError, "No such command");
return nullptr;
}
}
@@ -316,7 +316,7 @@ PyObject* CommandPy::getAction(PyObject *args)
return Py::new_reference_to(list);
}
else {
PyErr_Format(Base::BaseExceptionFreeCADError, "No such command");
PyErr_Format(Base::PyExc_FC_GeneralError, "No such command");
return nullptr;
}
}

View File

@@ -115,7 +115,7 @@ PyObject* DocumentPy::setEdit(PyObject *args)
if (PyArg_ParseTuple(args, "s|is", &psFeatStr,&mod,&subname)) {
obj = getDocumentPtr()->getDocument()->getObject(psFeatStr);
if (!obj) {
PyErr_Format(Base::BaseExceptionFreeCADError, "No such object found in document: '%s'", psFeatStr);
PyErr_Format(Base::PyExc_FC_GeneralError, "No such object found in document: '%s'", psFeatStr);
return nullptr;
}
}

View File

@@ -2050,7 +2050,7 @@ PyObject *SelectionSingleton::sAddSelection(PyObject * /*self*/, PyObject *args)
App::DocumentObjectPy* docObjPy = static_cast<App::DocumentObjectPy*>(object);
App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr();
if (!docObj || !docObj->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot check invalid object");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check invalid object");
return nullptr;
}
@@ -2068,7 +2068,7 @@ PyObject *SelectionSingleton::sAddSelection(PyObject * /*self*/, PyObject *args)
App::DocumentObjectPy* docObjPy = static_cast<App::DocumentObjectPy*>(object);
App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr();
if (!docObj || !docObj->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot check invalid object");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check invalid object");
return nullptr;
}
@@ -2107,7 +2107,7 @@ PyObject *SelectionSingleton::sUpdateSelection(PyObject * /*self*/, PyObject *ar
App::DocumentObjectPy* docObjPy = static_cast<App::DocumentObjectPy*>(object);
App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr();
if (!docObj || !docObj->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot check invalid object");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check invalid object");
return nullptr;
}
@@ -2137,7 +2137,7 @@ PyObject *SelectionSingleton::sRemoveSelection(PyObject * /*self*/, PyObject *ar
App::DocumentObjectPy* docObjPy = static_cast<App::DocumentObjectPy*>(object);
App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr();
if (!docObj || !docObj->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot check invalid object");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check invalid object");
return nullptr;
}
@@ -2244,7 +2244,7 @@ PyObject *SelectionSingleton::sSetPreselection(PyObject * /*self*/, PyObject *ar
App::DocumentObjectPy* docObjPy = static_cast<App::DocumentObjectPy*>(object);
App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr();
if (!docObj || !docObj->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot check invalid object");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check invalid object");
return nullptr;
}

View File

@@ -222,7 +222,7 @@ FreeCADGui_embedToWindow(PyObject * /*self*/, PyObject *args)
QWidget* widget = Gui::getMainWindow();
if (!widget) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "No main window");
PyErr_SetString(Base::PyExc_FC_GeneralError, "No main window");
return 0;
}
@@ -320,7 +320,7 @@ QWidget* setupMainWindow()
Base::Interpreter().runString(Base::ScriptFactory().ProduceScript("FreeCADGuiInit"));
}
catch (const Base::Exception& e) {
PyErr_Format(Base::BaseExceptionFreeCADError, "Error in FreeCADGuiInit.py: %s\n", e.what());
PyErr_Format(Base::PyExc_FC_GeneralError, "Error in FreeCADGuiInit.py: %s\n", e.what());
return 0;
}
init = true;

View File

@@ -100,7 +100,7 @@ int FemMeshPy::PyInit(PyObject* args, PyObject* /*kwd*/)
return -1;
}
catch (const std::exception &e) {
PyErr_SetString(Base::BaseExceptionFreeCADError,e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError,e.what());
return -1;
}
catch (const Py::Exception&) {
@@ -124,7 +124,7 @@ PyObject* FemMeshPy::setShape(PyObject *args)
getFemMeshPtr()->getSMesh()->ShapeToMesh(shape);
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
Py_Return;
@@ -155,7 +155,7 @@ PyObject* FemMeshPy::addHypothesis(PyObject *args)
return 0;
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
Py_Return;
@@ -170,7 +170,7 @@ PyObject* FemMeshPy::setStandardHypotheses(PyObject *args)
getFemMeshPtr()->setStandardHypotheses();
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
Py_Return;
@@ -185,7 +185,7 @@ PyObject* FemMeshPy::compute(PyObject *args)
getFemMeshPtr()->compute();
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
Py_Return;
@@ -205,7 +205,7 @@ PyObject* FemMeshPy::addNode(PyObject *args)
return Py::new_reference_to(Py::Long(node->GetID()));
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
}
@@ -221,7 +221,7 @@ PyObject* FemMeshPy::addNode(PyObject *args)
return Py::new_reference_to(Py::Long(node->GetID()));
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
}
@@ -249,7 +249,7 @@ PyObject* FemMeshPy::addEdge(PyObject *args)
return Py::new_reference_to(Py::Long(edge->GetID()));
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
}
@@ -331,7 +331,7 @@ PyObject* FemMeshPy::addFace(PyObject *args)
return Py::new_reference_to(Py::Long(face->GetID()));
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
}
@@ -434,7 +434,7 @@ PyObject* FemMeshPy::addQuad(PyObject *args)
return Py::new_reference_to(Py::Long(face->GetID()));
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
}
@@ -460,7 +460,7 @@ PyObject* FemMeshPy::addVolume(PyObject *args)
return Py::new_reference_to(Py::Long(vol->GetID()));
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
}
@@ -601,7 +601,7 @@ PyObject* FemMeshPy::read(PyObject *args)
getFemMeshPtr()->read(EncodedName.c_str());
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
Py_Return;
@@ -619,7 +619,7 @@ PyObject* FemMeshPy::write(PyObject *args)
getFemMeshPtr()->write(EncodedName.c_str());
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
Py_Return;
@@ -640,7 +640,7 @@ PyObject* FemMeshPy::writeABAQUS(PyObject *args)
getFemMeshPtr()->writeABAQUS(EncodedName.c_str(), elemParam, grpParam);
}
catch (const std::exception& e) {
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return 0;
}
Py_Return;

View File

@@ -91,7 +91,7 @@ private:
if (PyArg_ParseTuple(args.ptr(),"|O!",&(App::DocumentObjectPy::Type), &object)&& object) {
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(object)->getDocumentObjectPtr();
if (!obj || !obj->getTypeId().isDerivedFrom(Fem::FemAnalysis::getClassTypeId())){
throw Py::Exception(Base::BaseExceptionFreeCADError, "Active Analysis object have to be of type Fem::FemAnalysis!");
throw Py::Exception(Base::PyExc_FC_GeneralError, "Active Analysis object have to be of type Fem::FemAnalysis!");
}
// get the gui document of the Analysis Item

View File

@@ -275,7 +275,7 @@ private:
}
}
catch (Standard_Failure& e) {
throw Py::Exception(Base::BaseExceptionFreeCADError, e.GetMessageString());
throw Py::Exception(Base::PyExc_FC_GeneralError, e.GetMessageString());
}
catch (const Base::Exception& e) {
e.setPyException();
@@ -396,7 +396,7 @@ private:
hApp->Close(hDoc);
}
catch (Standard_Failure& e) {
throw Py::Exception(Base::BaseExceptionFreeCADError, e.GetMessageString());
throw Py::Exception(Base::PyExc_FC_GeneralError, e.GetMessageString());
}
catch (const Base::Exception& e) {
e.setPyException();

View File

@@ -556,7 +556,7 @@ private:
}
}
catch (Standard_Failure& e) {
throw Py::Exception(Base::BaseExceptionFreeCADError, e.GetMessageString());
throw Py::Exception(Base::PyExc_FC_GeneralError, e.GetMessageString());
}
catch (const Base::Exception& e) {
e.setPyException();
@@ -713,7 +713,7 @@ private:
hApp->Close(hDoc);
}
catch (Standard_Failure& e) {
throw Py::Exception(Base::BaseExceptionFreeCADError, e.GetMessageString());
throw Py::Exception(Base::PyExc_FC_GeneralError, e.GetMessageString());
}
catch (const Base::Exception& e) {
e.setPyException();
@@ -817,7 +817,7 @@ private:
hApp->Close(hDoc);
}
catch (Standard_Failure& e) {
throw Py::Exception(Base::BaseExceptionFreeCADError, e.GetMessageString());
throw Py::Exception(Base::PyExc_FC_GeneralError, e.GetMessageString());
}
catch (const Base::Exception& e) {
e.setPyException();

View File

@@ -102,7 +102,7 @@ int MeshPy::PyInit(PyObject* args, PyObject*)
return -1;
}
catch (const std::exception &e) {
PyErr_SetString(Base::BaseExceptionFreeCADError,e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError,e.what());
return -1;
}
catch (const Py::Exception&) {

View File

@@ -160,7 +160,7 @@ private:
if (msg) {str += msg;}
else {str += "No OCCT Exception Message";}
Base::Console().Error("%s\n", str.c_str());
throw Py::Exception(Base::BaseExceptionFreeCADError, str);
throw Py::Exception(Base::PyExc_FC_GeneralError, str);
}
catch (const Base::Exception &e) {
std::string str;

View File

@@ -196,8 +196,8 @@ PyMOD_INIT_FUNC(Part)
// Python exceptions
//
PyObject* OCCError = 0;
if (PyObject_IsSubclass(Base::BaseExceptionFreeCADError, PyExc_RuntimeError)) {
OCCError = PyErr_NewException("Part.OCCError", Base::BaseExceptionFreeCADError, NULL);
if (PyObject_IsSubclass(Base::PyExc_FC_GeneralError, PyExc_RuntimeError)) {
OCCError = PyErr_NewException("Part.OCCError", Base::PyExc_FC_GeneralError, NULL);
}
else {
Base::Console().Error("Can not inherit Part.OCCError form BaseFreeCADError.\n");

View File

@@ -79,7 +79,7 @@ int AttachEnginePy::PyInit(PyObject* args, PyObject* /*kwd*/)
if (!pNewAttacher) {
std::stringstream errMsg;
errMsg << "Object if this type is not derived from AttachEngine: " << typeName;
PyErr_SetString(Base::BaseExceptionFreeCADError, errMsg.str().c_str());
PyErr_SetString(Base::PyExc_FC_GeneralError, errMsg.str().c_str());
return -1;
}
AttachEngine* oldAttacher = this->getAttachEnginePtr();
@@ -250,7 +250,7 @@ Py::List AttachEnginePy::getImplementedModes(void) const
PyErr_SetString(Part::PartExceptionOCCError, e.GetMessageString());\
return NULL;\
} catch (Base::Exception &e) {\
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());\
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());\
return NULL;\
} catch (const Py::Exception &){\
return NULL;\

View File

@@ -572,7 +572,7 @@ PyObject* TopoShapePy::__getstate__(PyObject *args) {
PyObject* TopoShapePy::__setstate__(PyObject *args) {
if (! getTopoShapePtr()) {
PyErr_SetString(Base::BaseExceptionFreeCADError,"no c++ object");
PyErr_SetString(Base::PyExc_FC_GeneralError,"no c++ object");
return 0;
}
else {
@@ -2926,7 +2926,7 @@ Py::String TopoShapePy::getShapeType(void) const
{
TopoDS_Shape sh = getTopoShapePtr()->getShape();
if (sh.IsNull())
throw Py::Exception(Base::BaseExceptionFreeCADError, "cannot determine type of null shape");
throw Py::Exception(Base::PyExc_FC_GeneralError, "cannot determine type of null shape");
TopAbs_ShapeEnum type = sh.ShapeType();
std::string name;
switch (type)
@@ -2967,7 +2967,7 @@ Py::String TopoShapePy::getOrientation(void) const
{
TopoDS_Shape sh = getTopoShapePtr()->getShape();
if (sh.IsNull())
throw Py::Exception(Base::BaseExceptionFreeCADError, "cannot determine orientation of null shape");
throw Py::Exception(Base::PyExc_FC_GeneralError, "cannot determine orientation of null shape");
TopAbs_Orientation type = sh.Orientation();
std::string name;
switch (type)
@@ -2993,7 +2993,7 @@ void TopoShapePy::setOrientation(Py::String arg)
{
TopoDS_Shape sh = getTopoShapePtr()->getShape();
if (sh.IsNull())
throw Py::Exception(Base::BaseExceptionFreeCADError, "cannot determine orientation of null shape");
throw Py::Exception(Base::PyExc_FC_GeneralError, "cannot determine orientation of null shape");
std::string name = (std::string)arg;
TopAbs_Orientation type;
if (name == "Forward") {

View File

@@ -76,7 +76,7 @@
str += e.what(); \
str += ")"; \
e.ReportException(); \
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());\
PyErr_SetString(Base::PyExc_FC_GeneralError,str.c_str());\
} \
catch(std::exception &e) \
{ \
@@ -85,11 +85,11 @@
str += e.what(); \
str += ")"; \
Base::Console().Error(str.c_str()); \
PyErr_SetString(Base::BaseExceptionFreeCADError,str.c_str());\
PyErr_SetString(Base::PyExc_FC_GeneralError,str.c_str());\
} \
catch(const char *e) \
{ \
PyErr_SetString(Base::BaseExceptionFreeCADError,e); \
PyErr_SetString(Base::PyExc_FC_GeneralError,e); \
} throw Py::Exception();
namespace Path {

View File

@@ -48,15 +48,15 @@ PyObject* FeaturePathCompoundPy::addObject(PyObject *args)
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot add an invalid object");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot add an invalid object");
return nullptr;
}
if (docObj->getDocumentObjectPtr()->getDocument() != getFeaturePathCompoundPtr()->getDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot add an object from another document to this group");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot add an object from another document to this group");
return nullptr;
}
if (docObj->getDocumentObjectPtr() == this->getFeaturePathCompoundPtr()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot add a group object to itself");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot add a group object to itself");
return nullptr;
}
@@ -93,11 +93,11 @@ PyObject* FeaturePathCompoundPy::removeObject(PyObject *args)
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot remove an invalid object");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot remove an invalid object");
return nullptr;
}
if (docObj->getDocumentObjectPtr()->getDocument() != getFeaturePathCompoundPtr()->getDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot remove an object from another document from this group");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot remove an object from another document from this group");
return nullptr;
}

View File

@@ -572,13 +572,13 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject
{
auto pye = e.getPyExceptionType();
if(!pye)
pye = Base::BaseExceptionFreeCADError;
PyErr_SetObject(pye,e.getPyObject());
pye = Base::PyExc_FC_GeneralError;
PyErr_SetObject(pye, e.getPyObject());
return nullptr;
}
catch(const std::exception &e)
{
PyErr_SetString(Base::BaseExceptionFreeCADError,e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return nullptr;
}
catch(const Py::Exception&)
@@ -589,7 +589,7 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject
#ifndef DONT_CATCH_CXX_EXCEPTIONS
catch(...)
{
PyErr_SetString(Base::BaseExceptionFreeCADError,"Unknown C++ exception");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Unknown C++ exception");
return nullptr;
}
#endif
@@ -613,7 +613,7 @@ PyObject * @self.export.Name@::staticCallback_get@i.Name@ (PyObject *self, void
// The exception text is already set
return nullptr;
} catch (...) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Unknown exception while reading attribute '@i.Name@' of object '@self.export.Twin@'");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Unknown exception while reading attribute '@i.Name@' of object '@self.export.Twin@'");
return nullptr;
}
}
@@ -652,7 +652,7 @@ int @self.export.Name@::staticCallback_set@i.Name@ (PyObject *self, PyObject *va
// The exception text is already set
return -1;
} catch (...) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Unknown exception while writing attribute '@i.Name@' of object '@self.export.Twin@'");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Unknown exception while writing attribute '@i.Name@' of object '@self.export.Twin@'");
return -1;
}
}
@@ -735,13 +735,13 @@ PyObject *@self.export.Name@::_getattr(const char *attr) // __getattr__ functi
{
auto pye = e.getPyExceptionType();
if(!pye)
pye = Base::BaseExceptionFreeCADError;
PyErr_SetObject(pye,e.getPyObject());
pye = Base::PyExc_FC_GeneralError;
PyErr_SetObject(pye, e.getPyObject());
return nullptr;
}
catch(const std::exception &e)
{
PyErr_SetString(Base::BaseExceptionFreeCADError,e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return nullptr;
}
catch(const Py::Exception&)
@@ -752,7 +752,7 @@ PyObject *@self.export.Name@::_getattr(const char *attr) // __getattr__ functi
#ifndef DONT_CATCH_CXX_EXCEPTIONS
catch(...)
{
PyErr_SetString(Base::BaseExceptionFreeCADError,"Unknown C++ exception");
PyErr_SetString(Base::PyExc_FC_GeneralError,"Unknown C++ exception");
return nullptr;
}
#endif
@@ -785,13 +785,13 @@ int @self.export.Name@::_setattr(const char *attr, PyObject *value) // __setattr
{
auto pye = e.getPyExceptionType();
if(!pye)
pye = Base::BaseExceptionFreeCADError;
PyErr_SetObject(pye,e.getPyObject());
pye = Base::PyExc_FC_GeneralError;
PyErr_SetObject(pye, e.getPyObject());
return -1;
}
catch(const std::exception &e)
{
PyErr_SetString(Base::BaseExceptionFreeCADError,e.what());
PyErr_SetString(Base::PyExc_FC_GeneralError, e.what());
return -1;
}
catch(const Py::Exception&)
@@ -802,7 +802,7 @@ int @self.export.Name@::_setattr(const char *attr, PyObject *value) // __setattr
#ifndef DONT_CATCH_CXX_EXCEPTIONS
catch(...)
{
PyErr_SetString(Base::BaseExceptionFreeCADError,"Unknown C++ exception");
PyErr_SetString(Base::PyExc_FC_GeneralError, "Unknown C++ exception");
return -1;
}
#endif