PetterKraabol / Twitch-Python

Object-oriented Twitch API for Python developers
https://pypi.org/project/twitch-python
MIT License
213 stars 37 forks source link

IRC login error handling #32

Open HoodyH opened 3 years ago

HoodyH commented 3 years ago

hi, it would be cool if you rise an error when there is an auth failure.

on the irc.py line 36

logging.fatal('IRC authentication error: ' + text or '')
#return
raise Exception('authentication error') 

even better if you create an exceptions.py file:

class AuthenticationError(Exception)
    pass
logging.fatal('IRC authentication error: ' + text or '')
raise AuthenticationError

So we can handle it, renewing the token or skipping the login. In my case im trying to handle multiple bots so its usefull

ty

RduMarais commented 1 year ago

+1 This would be super useful indeed, in order to catch error and create renewal process. Out of curiosity, @HoodyH did you find a way to catch the error without modifying the lib ? thx

RduMarais commented 1 year ago

Had a look into it, and the fix you proposed seems trivial but actually doesn't work because the library is threaded, so the exception is raised in the context of a child thread, but cannot be caught in the main thread. I look forward into it, but i'd be happy to get any insight on another (more pythonic) way to catch this