+ improve exception handling in initialization scripts
This commit is contained in:
parent
9f4dc4616c
commit
e9e9a38865
|
@ -36,7 +36,7 @@ import FreeCAD
|
|||
|
||||
def InitApplications():
|
||||
try:
|
||||
import sys,os
|
||||
import sys,os,traceback,cStringIO
|
||||
except ImportError:
|
||||
FreeCAD.PrintError("\n\nSeems the python standard libs are not installed, bailing out!\n\n")
|
||||
raise
|
||||
|
@ -96,7 +96,12 @@ def InitApplications():
|
|||
exec open(InstallFile).read()
|
||||
except Exception, inst:
|
||||
Log('Init: Initializing ' + Dir + '... failed\n')
|
||||
Err('During initialization the error ' + str(inst) + ' occurred in ' + InstallFile + '\n')
|
||||
Log('-'*100+'\n')
|
||||
output=cStringIO.StringIO()
|
||||
traceback.print_exc(file=output)
|
||||
Log(output.getvalue())
|
||||
Log('-'*100+'\n')
|
||||
Err('During initialization the error ' + str(inst).decode('ascii','replace') + ' occurred in ' + InstallFile + '\n')
|
||||
else:
|
||||
Log('Init: Initializing ' + Dir + '... done\n')
|
||||
else:
|
||||
|
|
|
@ -159,6 +159,9 @@ std::string InterpreterSingleton::runString(const char *sCmd)
|
|||
|
||||
presult = PyRun_String(sCmd, Py_file_input, dict, dict); /* eval direct */
|
||||
if (!presult) {
|
||||
if (PyErr_ExceptionMatches(PyExc_SystemExit))
|
||||
throw SystemExitException();
|
||||
else
|
||||
throw PyException();
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class NoneWorkbench ( Workbench ):
|
|||
return "Gui::NoneWorkbench"
|
||||
|
||||
def InitApplications():
|
||||
import sys,os
|
||||
import sys,os,traceback,cStringIO
|
||||
# Searching modules dirs +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
# (additional module paths are already cached)
|
||||
ModDirs = FreeCAD.__path__
|
||||
|
@ -113,7 +113,12 @@ def InitApplications():
|
|||
exec open(InstallFile).read()
|
||||
except Exception, inst:
|
||||
Log('Init: Initializing ' + Dir + '... failed\n')
|
||||
Err('During initialization the error ' + str(inst) + ' occurred in ' + InstallFile + '\n')
|
||||
Log('-'*100+'\n')
|
||||
output=cStringIO.StringIO()
|
||||
traceback.print_exc(file=output)
|
||||
Log(output.getvalue())
|
||||
Log('-'*100+'\n')
|
||||
Err('During initialization the error ' + str(inst).decode('ascii','replace') + ' occurred in ' + InstallFile + '\n')
|
||||
else:
|
||||
Log('Init: Initializing ' + Dir + '... done\n')
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user