From a58ecba67399350465fef463608a0ffed75fdd02 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 10 Mar 2020 13:45:26 +0100 Subject: [PATCH] Part: [skip ci] do not print an error message if a sub-object of a Part feature cannot be found Forum thread: https://forum.freecadweb.org/viewtopic.php?f=19&t=42216 --- src/Mod/Part/App/PartFeature.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Mod/Part/App/PartFeature.cpp b/src/Mod/Part/App/PartFeature.cpp index 15059485c7..47dc264ba7 100644 --- a/src/Mod/Part/App/PartFeature.cpp +++ b/src/Mod/Part/App/PartFeature.cpp @@ -25,7 +25,6 @@ #ifndef _PreComp_ # include - # include # include # include @@ -36,6 +35,7 @@ # include # include # include +# include # include # include # include // for Precision::Confusion() @@ -179,16 +179,27 @@ App::DocumentObject *Feature::getSubObject(const char *subname, } *pyObj = Py::new_reference_to(shape2pyshape(ts)); return const_cast(this); - }catch(Standard_Failure &e) { + } + catch(Standard_Failure &e) { + // FIXME: Do not handle the exception here because it leads to a flood of irrelevant and + // annoying error messages. + // For example: https://forum.freecadweb.org/viewtopic.php?f=19&t=42216 + // Instead either raise a sub-class of Base::Exception and let it handle by the calling + // instance or do simply nothing. For now the error message is degraded to a log message. std::ostringstream str; Standard_CString msg = e.GetMessageString(); +#if OCC_VERSION_HEX >= 0x070000 + // Avoid name mangling + str << e.DynamicType()->get_type_name() << " "; +#else str << typeid(e).name() << " "; +#endif if (msg) {str << msg;} else {str << "No OCCT Exception Message";} str << ": " << getFullName(); if (subname) str << '.' << subname; - FC_ERR(str.str()); + FC_LOG(str.str()); return 0; } }