show traceback of first error instead of last one

Change-Id: Iee418dcfb1d81a16112eed57b03c86242c2128b4
This commit is contained in:
zolliker 2021-10-06 08:34:56 +02:00
parent 929f55055e
commit cbb005d942
2 changed files with 8 additions and 4 deletions

View File

@ -29,6 +29,7 @@ import threading
import traceback
from os import environ, path
repodir = path.abspath(path.join(path.dirname(__file__), '..', '..'))
if path.splitext(sys.executable)[1] == ".exe" and not path.basename(sys.executable).startswith('python'):

View File

@ -232,7 +232,7 @@ class Server:
if opts:
errors.append(self.unknown_options(cls, opts))
self.modules = OrderedDict()
failure_traceback = None # traceback for the last error
failure_traceback = None # traceback for the first error
failed = set() # python modules failed to load
self.lastError = None
for modname, options in self.module_cfg.items():
@ -249,7 +249,8 @@ class Server:
errors.append('%s not found' % classname)
else:
failed.add(pymodule)
failure_traceback = traceback.format_exc()
if failure_traceback is None:
failure_traceback = traceback.format_exc()
errors.append('error importing %s' % classname)
else:
try:
@ -263,7 +264,8 @@ class Server:
for errtxt in e.args[0] if isinstance(e.args[0], list) else [e.args[0]]:
errors.append(' ' + errtxt)
except Exception:
failure_traceback = traceback.format_exc()
if failure_traceback is None:
failure_traceback = traceback.format_exc()
errors.append('error creating %s' % modname)
poll_table = dict()
@ -292,7 +294,8 @@ class Server:
try:
modobj.initModule()
except Exception as e:
failure_traceback = traceback.format_exc()
if failure_traceback is None:
failure_traceback = traceback.format_exc()
errors.append('error initializing %s: %r' % (modname, e))
if errors: