Py: replace BaseExceptionFreeCADError with more suitable exception types

This commit is contained in:
wmayer
2022-03-17 13:54:23 +01:00
parent d84fd8a2df
commit d69defaa3c
38 changed files with 148 additions and 133 deletions

View File

@@ -77,7 +77,7 @@ int AxisPy::PyInit(PyObject* args, PyObject* /*kwd*/)
return 0;
}
PyErr_SetString(Base::BaseExceptionFreeCADError, "empty parameter list, axis or base and direction expected");
PyErr_SetString(PyExc_TypeError, "empty parameter list, axis or base and direction expected");
return -1;
}

View File

@@ -181,7 +181,7 @@ const char* AbortException::what() const throw()
PyObject * AbortException::getPyExceptionType() const
{
return BaseExceptionFreeCADAbort;
return PyExc_FC_FreeCADAbort;
}
// ---------------------------------------------------------

View File

@@ -112,7 +112,7 @@ void PyException::raiseException() {
PP_PyDict_Object = nullptr;
std::string exceptionname;
if (_exceptionType == Base::BaseExceptionFreeCADAbort)
if (_exceptionType == Base::PyExc_FC_FreeCADAbort)
edict.setItem("sclassname",
Py::String(typeid(Base::AbortException).name()));
if (_isReported)
@@ -120,7 +120,7 @@ void PyException::raiseException() {
Base::ExceptionFactory::Instance().raiseException(edict.ptr());
}
if (_exceptionType == Base::BaseExceptionFreeCADAbort) {
if (_exceptionType == Base::PyExc_FC_FreeCADAbort) {
Base::AbortException e(_sErrMsg.c_str());
e.setReported(_isReported);
throw e;

View File

@@ -120,7 +120,7 @@ int MatrixPy::PyInit(PyObject* args, PyObject* /*kwd*/)
return 0;
}
PyErr_SetString(Base::BaseExceptionFreeCADError, "matrix or up to 16 floats expected");
PyErr_SetString(PyExc_TypeError, "matrix or up to 16 floats expected");
return -1;
}
@@ -610,7 +610,7 @@ PyObject* MatrixPy::multiply(PyObject * args)
return new VectorPy(new Vector3d(vec));
}
PyErr_SetString(Base::BaseExceptionFreeCADError, "either vector or matrix expected");
PyErr_SetString(PyExc_TypeError, "either vector or matrix expected");
return nullptr;
}

View File

@@ -114,7 +114,7 @@ int PlacementPy::PyInit(PyObject* args, PyObject* /*kwd*/)
return 0;
}
PyErr_SetString(Base::BaseExceptionFreeCADError, "empty parameter list, matrix or placement expected");
PyErr_SetString(PyExc_TypeError, "empty parameter list, matrix or placement expected");
return -1;
}

View File

@@ -37,7 +37,7 @@
using namespace Base;
PyObject* Base::BaseExceptionFreeCADError = nullptr;
PyObject* Base::BaseExceptionFreeCADAbort = nullptr;
PyObject* Base::PyExc_FC_FreeCADAbort = nullptr;
PyObject* Base::PyExc_FC_XMLBaseException = nullptr;
PyObject* Base::PyExc_FC_XMLParseException = nullptr;
PyObject* Base::PyExc_FC_XMLAttributeError = nullptr;

View File

@@ -414,7 +414,7 @@ BaseExport extern PyObject* BaseExceptionFreeCADError;
#define PY_FCERROR (Base::BaseExceptionFreeCADError ? \
BaseExceptionFreeCADError : PyExc_RuntimeError)
BaseExport extern PyObject* BaseExceptionFreeCADAbort;
BaseExport extern PyObject* PyExc_FC_FreeCADAbort;
BaseExport extern PyObject* PyExc_FC_XMLBaseException;
BaseExport extern PyObject* PyExc_FC_XMLParseException;
BaseExport extern PyObject* PyExc_FC_XMLAttributeError;