VickiLanger / code-questions-bot

A Twitter bot who tweets code questions and trivia
https://vickilanger.github.io/code-questions-bot/
GNU General Public License v3.0
35 stars 18 forks source link

Add Exception Handling #8

Open VickiLanger opened 4 years ago

VickiLanger commented 4 years ago

Need to add exception handling to tweet.py

try:
    api.update_status(question)
except:
    # not sure what would go here?
finally:
    api.update_status('I seem to not be working properly. Bug @Vicki_Langer about getting me fixed or help her out by submitting a pull request https://github.com/VickiLanger/code-questions-bot')

Don't forget to follow the bot on Twitter to see the hard work you put in.

sroy8091 commented 3 years ago

@VickiLanger we can send a report email in case of exception, and keep on restarting the server after a configurable amount of time.

VickiLanger commented 3 years ago

@sroy8091 Yes, an email would work. That makes sense. I don't see why we couldn't restart the server until it works.

achoudh5 commented 3 years ago

@VickiLanger can we put the specific status code under except part?

Reference

VickiLanger commented 3 years ago

@achoudh5 that seems like it would make sense. Honestly, I have not done any exception handling outside of some practice. So, I'm not sure what it normally looks like.

achoudh5 commented 3 years ago

If I may ask, what I understood by tweet.py and this error handling case is that after making sure the user enters their credentials right, it's taking some questions from a pool of questions and putting them as tweet right?

VickiLanger commented 3 years ago

Yes. tweet.py uses questions from files in questions_dir

achoudh5 commented 3 years ago

Awesome! so, can we use an edge case file like if a user sends an empty tweet or some tweets they wants to avoid but since it's automated they don't have any control over it?

VickiLanger commented 3 years ago

Yes. That makes sense. An empty tweet definitely shouldn't happen.

achoudh5 commented 3 years ago

Is that the only case you want to consider for now? I can create a PR for that if it's fine

VickiLanger commented 3 years ago

That's the only thing I can think of. Go for it