Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

Catch thread exception #444

Open
chri-hub opened this issue Feb 3, 2019 · 0 comments
Open

Catch thread exception #444

chri-hub opened this issue Feb 3, 2019 · 0 comments

Comments

@chri-hub
Copy link

chri-hub commented Feb 3, 2019

Hi there,

i'm running a MessageLoop as thread. The Bot works fine, but i'm not able to catch an exception.
If an error occurs in the thread, i can't handle it in my program (e.g. the APIKEY is invalid).

Thanks

try:
    bot = telepot.DelegatorBot(APIKEY, [
        include_callback_query_chat_id(
            pave_event_space())(
                per_chat_id(types=['private']), create_open, ChatBot, timeout=10),
    ])
    MessageLoop(bot).run_as_thread()
    print('Listening ...')

    while 1:
        time.sleep(10)

except Exception as ex:
    print('Exception')
    ... some exception handling ... 
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant