Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Do not call sys.exit when the library encounters an error (!) #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

marmistrz
Copy link

@marmistrz marmistrz commented May 4, 2020

The code removed is an example how to write bad Python.
Blanket exception catching is bad. Exiting the whole application is atrocious, because it makes it impossible to handle errors. Exiting the whole application with EXIT_SUCCESS is a horror.

Besides, cleanup some whitespace.

Closes #67.

@Mottl
Copy link
Owner

Mottl commented May 5, 2020

Yes, exception handling and exiting application should be moved from library to executable (bin/GetOldTweets). I can merge your PR after you add the exceptions handling to a new place.

@yannikbenz
Copy link

yannikbenz commented Aug 8, 2020

Yes, exception handling and exiting application should be moved from library to executable (bin/GetOldTweets). I can merge your PR after you add the exceptions handling to a new place.

What about pushing some errors up to the user (especially the http exceptions)?

The most common errors here are Limit exceptions from Twitter itself - if we push them up to the user we can handle them and continue the execution e.g. after a short delay w/o manual interaction.

An error occured during an HTTP request: HTTP Error 429: Too Many Requests

@Aens
Copy link

Aens commented Sep 18, 2020

+1 to this. I wasn't aware of it and my entire application was crashing just because a 1% part of it was using this library to read some twits in another thread. Please never call sys.exit() on a library that it is supposed to be imported, as it will often be used as just 1 more module of a bigger application, and that module/thread alone shouldn't crash the entire application.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to handle a urlopen error?
4 participants