|
47 | 47 | # Get an instance of logger, which we'll pull from the config file |
48 | 48 | logger = logging.getLogger("VWFlash") |
49 | 49 |
|
| 50 | + |
50 | 51 | def handle_exception(exc_type, exc_value, exc_traceback): |
51 | 52 | if issubclass(exc_type, KeyboardInterrupt): |
52 | 53 | sys.__excepthook__(exc_type, exc_value, exc_traceback) |
53 | 54 | return |
54 | | - |
55 | 55 | logger.error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback)) |
| 56 | + dlg = wx.MessageDialog( |
| 57 | + None, |
| 58 | + f"A Python exception occured: {exc_type}, {exc_value}. Please check the log file.", |
| 59 | + "Error!", |
| 60 | + wx.OK | wx.ICON_ERROR | wx.CENTRE, |
| 61 | + ) |
| 62 | + dlg.ShowModal() |
| 63 | + dlg.Destroy() |
| 64 | + |
| 65 | + |
| 66 | +def handle_threaded_exception(args, /): |
| 67 | + (exc_type, exc_value, exc_traceback, thread) = args |
| 68 | + handle_exception(exc_type, exc_value, exc_traceback) |
56 | 69 |
|
57 | | - try: |
58 | | - wx.MessageDialog( |
59 | | - None, |
60 | | - f"A Python exception occured: {exc_type}, {exc_value}. Please check the log file.", |
61 | | - wx.OK | wx.ICON_ERROR | wx.CENTRE, |
62 | | - ).ShowModal() |
63 | | - finally: |
64 | | - return |
65 | 70 |
|
66 | 71 | sys.excepthook = handle_exception |
| 72 | +threading.excepthook = handle_threaded_exception |
67 | 73 |
|
68 | 74 | try: |
69 | 75 | currentPath = path.dirname(path.abspath(__file__)) |
|
0 commit comments