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

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