Skip to content

Introduce a general error handler#129

Merged
1over137 merged 2 commits intoFreeLanguageTools:masterfrom
RasmusRendal:errorhandler
Jan 28, 2024
Merged

Introduce a general error handler#129
1over137 merged 2 commits intoFreeLanguageTools:masterfrom
RasmusRendal:errorhandler

Conversation

@RasmusRendal
Copy link
Copy Markdown
Contributor

Uncaught exceptions will be caught by this handler, and it will present
a dialog with a stack trace, but also still print the error to the console.

Also, make issues fetching forvo clips throw exceptions, which is a
great way to test it.

Being able to see when something goes wrong is really a great usability improvement imho

@1over137
Copy link
Copy Markdown
Contributor

1over137 commented Jan 9, 2024

Looks good, but we should probably use the logger rather than printing so it can be seen more easily by people using it without a console. I notice that a lot of exceptions are getting caught at earlier levels, maybe some of that should be removed (especially by the QTimers it seems)

Uncaught exceptions will be caught by this handler, and it will present
a dialog with a stack trace, but also still print the error to the console.

Also, make issues fetching forvo clips throw exceptions, which is a
great way to test it
@RasmusRendal
Copy link
Copy Markdown
Contributor Author

I notice that a lot of exceptions are getting caught at earlier levels, maybe some of that should be removed (especially by the QTimers it seems)

I still think that catching exceptions other places is ideal. In many cases I think the following pattern'd be good:

try:
   get_forvo_audio():
except NetworkException:
    logger.exception("Error fetching audio")
    QMessageBox.Critical("Error fetching audio", "Could not connect to forvo.com. Please check that your network connection is up, and forvo.com is reachable")

Giving the error messages locally allows us to do something that's a bit more userfriendly, than long stacktraces.

@1over137 1over137 merged commit 8450599 into FreeLanguageTools:master Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants