Application quits on python exception

John Thornton dev at gnipsel.com
Wed Dec 13 21:54:03 GMT 2023


Not sure if this helps or not but in my main class in the init I have 
this line

         sys.excepthook = self.excepthook

Then this function catches most errors.

     def excepthook(self, exc_type, exc_value, tb):
         # extract the stack summary
         summary = traceback.extract_tb(tb)
         for frame_summary in summary:
             filename = frame_summary.filename
             frame_summary.filename = os.path.relpath(filename)

         # rebuild the traceback and build the error message
         msg = f'Mesact Version: {VERSION} Build Date: {BUILD_DATE}\n'
         msg += 
''.join(traceback.format_list(StackSummary.from_list(summary)))
         msg += f'{exc_type.__name__}\n'
         msg += f'{exc_value}\n'
         msg += 'Please file an issue at\n'
         msg += 'https://github.com/jethornton/mesact/issues'
         print(msg)
         dialogs.errorMsgOk(msg, 'PROGRAM ERROR' )

This catches most errors and pops up a mesage box with the error.

If this is not what you're asking sorry for the static.

JT

On 12/13/23 14:16, Patrick Stinson wrote:
> I’ve been using PyQt for years but this is my first pyqt6 app.
>
> It looks like new behavior that QApplication quits on the first python exception? Is there a way to disable this? Or am I spacing out something?
>
> Cheers,
> -Patrick
>
>
>


More information about the PyQt mailing list