Base: [skip ci] Coverity: Uncaught exception

This commit is contained in:
wmayer
2020-09-14 18:34:25 +02:00
parent 3a8a28ce92
commit 6199fbb25e
3 changed files with 46 additions and 20 deletions

View File

@@ -125,27 +125,32 @@ PyObject * Exception::getPyObject(void)
void Exception::setPyObject( PyObject * pydict)
{
if (pydict && Py::_Dict_Check(pydict)) {
Py::Dict edict(pydict);
if (edict.hasKey("sfile"))
_file = static_cast<std::string>(Py::String(edict.getItem("sfile")));
try {
if (pydict && Py::_Dict_Check(pydict)) {
Py::Dict edict(pydict);
if (edict.hasKey("sfile"))
_file = static_cast<std::string>(Py::String(edict.getItem("sfile")));
if (edict.hasKey("sfunction"))
_function = static_cast<std::string>(Py::String(edict.getItem("sfunction")));
if (edict.hasKey("sfunction"))
_function = static_cast<std::string>(Py::String(edict.getItem("sfunction")));
if (edict.hasKey("sErrMsg"))
_sErrMsg = static_cast<std::string>(Py::String(edict.getItem("sErrMsg")));
if (edict.hasKey("sErrMsg"))
_sErrMsg = static_cast<std::string>(Py::String(edict.getItem("sErrMsg")));
if (edict.hasKey("iline"))
if (edict.hasKey("iline"))
#if PY_MAJOR_VERSION >= 3
_line = static_cast<long>(Py::Long(edict.getItem("iline")));
_line = static_cast<long>(Py::Long(edict.getItem("iline")));
#else
_line = static_cast<int>(Py::Int(edict.getItem("iline")));
_line = static_cast<int>(Py::Int(edict.getItem("iline")));
#endif
if (edict.hasKey("btranslatable"))
_isTranslatable = static_cast<bool>(Py::Boolean(edict.getItem("btranslatable")));
if (edict.hasKey("breported"))
_isReported = static_cast<bool>(Py::Boolean(edict.getItem("breported")));
if (edict.hasKey("btranslatable"))
_isTranslatable = static_cast<bool>(Py::Boolean(edict.getItem("btranslatable")));
if (edict.hasKey("breported"))
_isReported = static_cast<bool>(Py::Boolean(edict.getItem("breported")));
}
}
catch (Py::Exception& e) {
e.clear(); // should never happen
}
}

View File

@@ -690,7 +690,8 @@ void Command::_runCommand(const char *file, int line, DoCmd_Type eType, const ch
try {
Base::Interpreter().runString(sCmd);
}catch(Py::Exception &) {
}
catch(Py::Exception &) {
Base::PyException::ThrowException();
}
}

View File

@@ -362,22 +362,42 @@ App::DocumentObject* TaskTransformedParameters::getSketchObject() const {
void TaskTransformedParameters::hideObject()
{
FCMD_OBJ_HIDE(getTopTransformedObject());
try {
FCMD_OBJ_HIDE(getTopTransformedObject());
}
catch (const Base::Exception& e) {
e.ReportException();
}
}
void TaskTransformedParameters::showObject()
{
FCMD_OBJ_SHOW(getTopTransformedObject());
try {
FCMD_OBJ_SHOW(getTopTransformedObject());
}
catch (const Base::Exception& e) {
e.ReportException();
}
}
void TaskTransformedParameters::hideBase()
{
FCMD_OBJ_HIDE(getBaseObject());
try {
FCMD_OBJ_HIDE(getBaseObject());
}
catch (const Base::Exception& e) {
e.ReportException();
}
}
void TaskTransformedParameters::showBase()
{
FCMD_OBJ_SHOW(getBaseObject());
try {
FCMD_OBJ_SHOW(getBaseObject());
}
catch (const Base::Exception& e) {
e.ReportException();
}
}
void TaskTransformedParameters::exitSelectionMode()