1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0031731: Draw Harness - colorize errors and exception messages

Draw_Interpretor, CommandCmd() - catched exceptions and messages put into Tcl string result
before throwing a Tcl exception (return 1) are now print in intense red (using Message::SendFail()).
Duplication of exception message in std::cout and Tcl output has been removed.

Draw Harness plugins have been updated to use either Message::SendFail() or theDI instead of std::cout/std::cerr
for printing colored error message before throwing a Tcl exception.
This commit is contained in:
kgv
2020-08-24 19:13:08 +03:00
parent 1d99a2baaa
commit d99f0355e3
98 changed files with 514 additions and 620 deletions

View File

@@ -23,6 +23,7 @@
#include <Draw_Appli.hxx>
#include <Draw_Drawable3D.hxx>
#include <Draw_Interpretor.hxx>
#include <Message.hxx>
#include <TDF_Label.hxx>
#include <TDF_ChildIterator.hxx>
@@ -50,14 +51,14 @@ static Standard_Integer DFBrowse (Draw_Interpretor& di,
{
if (n<2)
{
std::cout << "Use: " << a[0] << " document [brower_name]" << std::endl;
Message::SendFail() << "Use: " << a[0] << " document [brower_name]";
return 1;
}
Handle(TDF_Data) DF;
if (!DDF::GetDF (a[1], DF))
{
std::cout << "Error: document " << a[1] << " is not found" << std::endl;
Message::SendFail() << "Error: document " << a[1] << " is not found";
return 1;
}
@@ -78,8 +79,8 @@ static Standard_Integer DFBrowse (Draw_Interpretor& di,
}
else
{
std::cout << "Error: Could not load script " << aTclScript << std::endl;
std::cout << "Check environment variable CSF_DrawPluginDefaults" << std::endl;
Message::SendFail() << "Error: Could not load script " << aTclScript << "\n"
<< "Check environment variable CSF_DrawPluginDefaults";
}
// Call command dftree defined in dftree.tcl
@@ -106,7 +107,7 @@ static Standard_Integer DFOpenLabel (Draw_Interpretor& di,
Handle(DDF_Browser) browser = Handle(DDF_Browser)::DownCast (Draw::GetExisting (a[1]));
if (browser.IsNull())
{
std::cout << "Syntax error: browser '" << a[1] << "' not found\n";
Message::SendFail() << "Syntax error: browser '" << a[1] << "' not found";
return 1;
}
@@ -135,7 +136,7 @@ static Standard_Integer DFOpenAttributeList(Draw_Interpretor& di,
Handle(DDF_Browser) browser = Handle(DDF_Browser)::DownCast (Draw::GetExisting (a[1]));
if (browser.IsNull())
{
std::cout << "Syntax error: browser '" << a[1] << "' not found\n";
Message::SendFail() << "Syntax error: browser '" << a[1] << "' not found";
return 1;
}
@@ -168,7 +169,7 @@ static Standard_Integer DFOpenAttribute (Draw_Interpretor& di,
Handle(DDF_Browser) browser = Handle(DDF_Browser)::DownCast (Draw::GetExisting (a[1]));
if (browser.IsNull())
{
std::cout << "Syntax error: browser '" << a[1] << "' not found\n";
Message::SendFail() << "Syntax error: browser '" << a[1] << "' not found";
return 1;
}