FEM and Part: check if catched exception has an error message

This commit is contained in:
Bernd Hahnebach
2020-01-07 22:06:38 +01:00
parent 3b2bf60cdf
commit bb6228dde0
3 changed files with 20 additions and 12 deletions

View File

@@ -176,11 +176,13 @@ class _ViewProviderFemMeshGmsh:
return (reg_childs + gro_childs + bou_childs)
def onDelete(self, feature, subelements):
try:
for obj in self.claimChildren():
obj.ViewObject.show()
except Exception as err:
FreeCAD.Console.PrintError("Error in onDelete: " + err.message)
childs = self.claimChildren()
if len(childs) > 0:
try:
for obj in self.claimChildren():
obj.ViewObject.show()
except Exception as err:
FreeCAD.Console.PrintError("Error in onDelete: {0} \n".format(err))
return True
def canDragObjects(self):

View File

@@ -108,11 +108,13 @@ class _ViewProviderFemResultMechanical:
return [self.Object.Mesh] # claimChildren needs to return a list !
def onDelete(self, feature, subelements):
try:
for obj in self.claimChildren():
obj.ViewObject.show()
except Exception as err:
FreeCAD.Console.PrintError("Error in onDelete: {0} \n".format(err))
childs = self.claimChildren()
if len(childs) > 0:
try:
for obj in self.claimChildren():
obj.ViewObject.show()
except Exception as err:
FreeCAD.Console.PrintError("Error in onDelete: {0} \n".format(err))
return True

View File

@@ -97,10 +97,14 @@ def cmdCreateCompoundFilter(name):
FreeCADGui.doCommand("f.Proxy.execute(f)")
FreeCADGui.doCommand("f.purgeTouched()")
except Exception as err:
if hasattr(err, "message"):
error_string = err.message
else:
error_string = err
mb = QtGui.QMessageBox()
mb.setIcon(mb.Icon.Warning)
mb.setText(_translate("Part_CompoundFilter", "Computing the result failed with an error: \n\n{err}\n\nClick 'Continue' to create the feature anyway, or 'Abort' to cancel.", None)
.format(err=err.message))
mb.setText(_translate("Part_CompoundFilter", "Computing the result failed with an error: \n\n{errstr}\n\nClick 'Continue' to create the feature anyway, or 'Abort' to cancel.", None)
.format(errstr=error_string))
mb.setWindowTitle(_translate("Part_CompoundFilter", "Bad selection", None))
btnAbort = mb.addButton(QtGui.QMessageBox.StandardButton.Abort)
btnOK = mb.addButton(_translate("Part_SplitFeatures", "Continue", None), QtGui.QMessageBox.ButtonRole.ActionRole)