diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index 6c72bb7ec1..e40edb4e7b 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -88,19 +88,8 @@ PyObject* DocumentObjectPy::addProperty(PyObject *args) PyMem_Free(sDoc); } - App::Property* prop=0; - try { - prop = getDocumentObjectPtr()->addDynamicProperty(sType,sName,sGroup,sDocStr.c_str(),attr, + getDocumentObjectPtr()->addDynamicProperty(sType,sName,sGroup,sDocStr.c_str(),attr, PyObject_IsTrue(ro) ? true : false, PyObject_IsTrue(hd) ? true : false); - } - catch (const Base::Exception& e) { - throw Py::RuntimeError(e.what()); - } - if (!prop) { - std::stringstream str; - str << "No property found of type '" << sType << "'" << std::ends; - throw Py::Exception(Base::BaseExceptionFreeCADError,str.str()); - } return Py::new_reference_to(this); } @@ -111,13 +100,8 @@ PyObject* DocumentObjectPy::removeProperty(PyObject *args) if (!PyArg_ParseTuple(args, "s", &sName)) return NULL; - try { - bool ok = getDocumentObjectPtr()->removeDynamicProperty(sName); - return Py_BuildValue("O", (ok ? Py_True : Py_False)); - } - catch (const Base::Exception& e) { - throw Py::RuntimeError(e.what()); - } + bool ok = getDocumentObjectPtr()->removeDynamicProperty(sName); + return Py_BuildValue("O", (ok ? Py_True : Py_False)); } PyObject* DocumentObjectPy::supportedProperties(PyObject *args) diff --git a/src/App/DynamicProperty.cpp b/src/App/DynamicProperty.cpp index c7d8fe359a..45ef89051c 100644 --- a/src/App/DynamicProperty.cpp +++ b/src/App/DynamicProperty.cpp @@ -183,7 +183,7 @@ Property* DynamicProperty::addDynamicProperty(PropertyContainer &pc, const char* Base::Type propType = Base::Type::getTypeIfDerivedFrom(type, App::Property::getClassTypeId(), true); if (propType.isBad()) { - FC_THROWM(Base::ValueError, "Invalid type " + FC_THROWM(Base::TypeError, "Invalid type " << type << " for property " << pc.getFullName() << '.' << name); } diff --git a/src/Mod/Test/Document.py b/src/Mod/Test/Document.py index 16458ffa21..8438ab977f 100644 --- a/src/Mod/Test/Document.py +++ b/src/Mod/Test/Document.py @@ -205,7 +205,7 @@ class DocumentBasicCases(unittest.TestCase): self.assertEqual(ext.createInstance(), None) obj = self.Doc.addObject("App::FeaturePython", "Object") - with self.assertRaises(RuntimeError): + with self.assertRaises(TypeError): obj.addProperty("App::DocumentObjectExtension", "Property") with self.assertRaises(TypeError):