IDE: in case of unhandled exception, write bug report to given log file, so that test report can have it. wxPython4
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Tue, 29 Mar 2022 08:19:46 +0200
branchwxPython4
changeset 3444 91b2c014494e
parent 3443 a47d9debb0d9
child 3445 83545348403e
IDE: in case of unhandled exception, write bug report to given log file, so that test report can have it.
Beremiz.py
util/ExceptionHandler.py
--- a/Beremiz.py	Tue Mar 22 14:51:30 2022 +0100
+++ b/Beremiz.py	Tue Mar 29 08:19:46 2022 +0200
@@ -186,7 +186,7 @@
     def InstallExceptionHandler(self):
         import version
         import util.ExceptionHandler
-        self.handle_exception = util.ExceptionHandler.AddExceptHook(version.app_version)
+        self.handle_exception = util.ExceptionHandler.AddExceptHook(version.app_version, logf=self.logf)
 
     def CreateUI(self):
         self.frame = self.BeremizIDE.Beremiz(None, self.projectOpen, self.buildpath, logf=self.logf)
--- a/util/ExceptionHandler.py	Tue Mar 22 14:51:30 2022 +0100
+++ b/util/ExceptionHandler.py	Tue Mar 29 08:19:46 2022 +0200
@@ -93,7 +93,7 @@
 ignored_exceptions = []  # a problem with a line in a module is only reported once per session
 
 
-def AddExceptHook(app_version='[No version]'):
+def AddExceptHook(app_version='[No version]', logf = None):
 
     def save_bug_report(e_type, e_value, e_traceback, bug_report_path, date):
         info = {
@@ -125,7 +125,10 @@
         lst = info.keys()
         lst.sort()
         for a in lst:
-            output.write(a + ":\n" + str(info[a]) + "\n\n")
+            line = a + ":\n" + str(info[a]) + "\n\n"
+            output.write(line)
+            if logf is not None:
+                logf.write(line)
         output.close()
 
     def handle_exception(e_type, e_value, e_traceback, exit=False):