mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0030579: Draw Harness, Draw_Interpretor - catch exceptions other than Standard_Failure
This commit is contained in:
parent
d9166000fe
commit
f996b507d8
@ -112,16 +112,7 @@ namespace {
|
|||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
// MKV 29.03.05
|
static Standard_Integer CommandCmd (ClientData theClientData, Tcl_Interp* interp, Standard_Integer argc, const char* argv[])
|
||||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
|
|
||||||
static Standard_Integer CommandCmd
|
|
||||||
(ClientData theClientData, Tcl_Interp *interp,
|
|
||||||
Standard_Integer argc, const char* argv[])
|
|
||||||
#else
|
|
||||||
static Standard_Integer CommandCmd
|
|
||||||
(ClientData theClientData, Tcl_Interp *interp,
|
|
||||||
Standard_Integer argc, char* argv[])
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
static Standard_Integer code;
|
static Standard_Integer code;
|
||||||
code = TCL_OK;
|
code = TCL_OK;
|
||||||
@ -166,18 +157,10 @@ static Standard_Integer CommandCmd
|
|||||||
}
|
}
|
||||||
catch (Standard_Failure const& anException) {
|
catch (Standard_Failure const& anException) {
|
||||||
// fail if Draw_ExitOnCatch is set
|
// fail if Draw_ExitOnCatch is set
|
||||||
// MKV 29.03.05
|
std::cout << "An exception was caught " << anException << std::endl;
|
||||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
|
const char* toExitOnCatch = Tcl_GetVar (interp, "Draw_ExitOnCatch", TCL_GLOBAL_ONLY);
|
||||||
const char* cc = Tcl_GetVar(interp,
|
if (toExitOnCatch != NULL && Draw::Atoi (toExitOnCatch))
|
||||||
"Draw_ExitOnCatch",TCL_GLOBAL_ONLY);
|
{
|
||||||
#else
|
|
||||||
char* const cc = Tcl_GetVar(interp,
|
|
||||||
"Draw_ExitOnCatch",TCL_GLOBAL_ONLY);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cout << "An exception was caught " << anException << endl;
|
|
||||||
|
|
||||||
if (cc && Draw::Atoi(cc)) {
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
Tcl_Exit(0);
|
Tcl_Exit(0);
|
||||||
#else
|
#else
|
||||||
@ -191,6 +174,44 @@ static Standard_Integer CommandCmd
|
|||||||
Tcl_SetResult(interp,(char*)(ss.str().c_str()),TCL_VOLATILE);
|
Tcl_SetResult(interp,(char*)(ss.str().c_str()),TCL_VOLATILE);
|
||||||
code = TCL_ERROR;
|
code = TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
catch (std::exception const& theStdException)
|
||||||
|
{
|
||||||
|
std::cout << "An exception was caught " << theStdException.what() << " [" << typeid(theStdException).name() << "]" << std::endl;
|
||||||
|
const char* toExitOnCatch = Tcl_GetVar (interp, "Draw_ExitOnCatch", TCL_GLOBAL_ONLY);
|
||||||
|
if (toExitOnCatch != NULL && Draw::Atoi (toExitOnCatch))
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
Tcl_Exit (0);
|
||||||
|
#else
|
||||||
|
Tcl_Eval (interp, "exit");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the error message
|
||||||
|
Standard_SStream ss;
|
||||||
|
ss << "** Exception ** " << theStdException.what() << " [" << typeid(theStdException).name() << "]" << ends;
|
||||||
|
Tcl_SetResult (interp, (char*)(ss.str().c_str()), TCL_VOLATILE);
|
||||||
|
code = TCL_ERROR;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
std::cout << "UNKNOWN exception was caught " << std::endl;
|
||||||
|
const char* toExitOnCatch = Tcl_GetVar (interp, "Draw_ExitOnCatch", TCL_GLOBAL_ONLY);
|
||||||
|
if (toExitOnCatch != NULL && Draw::Atoi (toExitOnCatch))
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
Tcl_Exit (0);
|
||||||
|
#else
|
||||||
|
Tcl_Eval (interp,"exit");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the error message
|
||||||
|
Standard_SStream ss;
|
||||||
|
ss << "** Exception ** UNKNOWN" << ends;
|
||||||
|
Tcl_SetResult (interp, (char* )(ss.str().c_str()), TCL_VOLATILE);
|
||||||
|
code = TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
// log command result
|
// log command result
|
||||||
if (doLog || doEcho)
|
if (doLog || doEcho)
|
||||||
|
@ -72,26 +72,16 @@ void Draw_Window::RemoveCallbackBeforeTerminate(FCallbackBeforeTerminate theCB)
|
|||||||
|
|
||||||
static void Prompt(Tcl_Interp *Interp, int partial)
|
static void Prompt(Tcl_Interp *Interp, int partial)
|
||||||
{
|
{
|
||||||
|
Tcl_Channel errChannel;
|
||||||
// MKV 29.03.05
|
Tcl_Channel outChannel = Tcl_GetStdChannel(TCL_STDOUT);
|
||||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
|
const char* promptCmd = Tcl_GetVar (Interp, partial ? "tcl_prompt2" : "tcl_prompt1", TCL_GLOBAL_ONLY);
|
||||||
const char *promptCmd;
|
|
||||||
#else
|
|
||||||
char *promptCmd;
|
|
||||||
#endif
|
|
||||||
int code;
|
|
||||||
Tcl_Channel outChannel, errChannel;
|
|
||||||
outChannel = Tcl_GetStdChannel(TCL_STDOUT);
|
|
||||||
promptCmd = Tcl_GetVar(Interp,(char*)
|
|
||||||
(partial ? "tcl_prompt2" : "tcl_prompt1"), TCL_GLOBAL_ONLY);
|
|
||||||
|
|
||||||
if (promptCmd == NULL) {
|
if (promptCmd == NULL) {
|
||||||
defaultPrompt:
|
defaultPrompt:
|
||||||
if (!partial && outChannel) {
|
if (!partial && outChannel) {
|
||||||
Tcl_Write(outChannel, "% ", 2);
|
Tcl_Write(outChannel, "% ", 2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
code = Tcl_Eval(Interp, promptCmd);
|
int code = Tcl_Eval(Interp, promptCmd);
|
||||||
outChannel = Tcl_GetStdChannel(TCL_STDOUT);
|
outChannel = Tcl_GetStdChannel(TCL_STDOUT);
|
||||||
errChannel = Tcl_GetStdChannel(TCL_STDERR);
|
errChannel = Tcl_GetStdChannel(TCL_STDERR);
|
||||||
if (code != TCL_OK) {
|
if (code != TCL_OK) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user