From 6cced4defbaada5e705ef760d20df64e3ee18778 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Thu, 1 Jun 2023 09:05:27 +0200 Subject: [PATCH] Gui: Command execution output for Developer only ================================================ Problem: Command execution templates currently are send to Console() error, which sends messages to both developers and users. A user sees an error message (for example in the notifications area) which is just the Python command that FreeCAD executed due to user's input. This annoys users who do not understand Python and it is not informative for them. It is however informative for a developer, who can associate which command produced which error/exception. Solution: To make these messages intended for the Developer only. So that regular users are not annoyed. Of course, Developers and power users can always select in preferences, under Notification Area to be shown debug errors and warnings. In which case nothing really changes. --- src/Gui/CommandT.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Gui/CommandT.h b/src/Gui/CommandT.h index a618c05c85..67116dfc87 100644 --- a/src/Gui/CommandT.h +++ b/src/Gui/CommandT.h @@ -262,10 +262,10 @@ void cmdAppDocumentArgs(const App::Document* doc, const std::string& cmd, Args&& doc->getName(), _cmd.c_str()); } catch (const std::exception& e) { - Base::Console().Error("%s: %s\n", e.what(), cmd.c_str()); + Base::Console().DeveloperError(doc->Label.getStrValue(),"%s: %s\n", e.what(), cmd.c_str()); } catch (const Base::Exception&) { - Base::Console().Error("App.getDocument('%s').%s\n", + Base::Console().DeveloperError(doc->Label.getStrValue(),"App.getDocument('%s').%s\n", doc->getName(), _cmd.c_str()); throw; } @@ -385,10 +385,10 @@ void cmdAppObjectArgs(const App::DocumentObject* obj, const std::string& cmd, Ar obj->getDocument()->getName(), obj->getNameInDocument(), _cmd.c_str()); } catch (const std::exception& e) { - Base::Console().Error("%s: %s\n", e.what(), cmd.c_str()); + Base::Console().DeveloperError(obj->getFullLabel(),"%s: %s\n", e.what(), cmd.c_str()); } catch (const Base::Exception&) { - Base::Console().Error("App.getDocument('%s').getObject('%s').%s\n", + Base::Console().DeveloperError(obj->getFullLabel(),"App.getDocument('%s').getObject('%s').%s\n", obj->getDocument()->getName(), obj->getNameInDocument(), _cmd.c_str()); throw; } @@ -410,10 +410,10 @@ void cmdGuiObjectArgs(const App::DocumentObject* obj, const std::string& cmd, Ar obj->getDocument()->getName(), obj->getNameInDocument(), _cmd.c_str()); } catch (const std::exception& e) { - Base::Console().Error("%s: %s\n", e.what(), cmd.c_str()); + Base::Console().DeveloperError(obj->getFullLabel(),"%s: %s\n", e.what(), cmd.c_str()); } catch (const Base::Exception&) { - Base::Console().Error("Gui.getDocument('%s').getObject('%s').%s\n", + Base::Console().DeveloperError(obj->getFullLabel(),"Gui.getDocument('%s').getObject('%s').%s\n", obj->getDocument()->getName(), obj->getNameInDocument(), _cmd.c_str()); throw; } @@ -443,10 +443,10 @@ void doCommandT(Gui::Command::DoCmd_Type cmdType, const std::string& cmd, Args&& Gui::Command::doCommand(cmdType,"%s", _cmd.c_str()); } catch (const std::exception& e) { - Base::Console().Error("%s: %s\n", e.what(), cmd.c_str()); + Base::Console().DeveloperError("doCommandT","%s: %s\n", e.what(), cmd.c_str()); } catch (const Base::Exception&) { - Base::Console().Error("%s\n", _cmd.c_str()); + Base::Console().DeveloperError("doCommandT","%s\n", _cmd.c_str()); throw; } }