Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(exception-handling): Catch errors when requesting datafile #285

Merged
merged 2 commits into from
Jul 10, 2020

Conversation

aliabbasrizvi
Copy link
Contributor

@aliabbasrizvi aliabbasrizvi commented Jul 10, 2020

Summary

We were not catching all exceptions when requesting the datafile. The HTTPError class is only a single class of errors and we were not capturing all the other errors like timeout issues, proxy issues, etc.

The class of exceptions can be seen here: https://requests.readthedocs.io/en/master/_modules/requests/exceptions

Updating to catch RequestException. It is also something we were already doing correctly in event dispatching: https://github.com/optimizely/python-sdk/blob/master/optimizely/event_dispatcher.py#L42

Test plan

  • Tested timeout before and after the fix.
  • Unit test added.

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Can we add some unit tests to make sure that we handle exceptions other than HTTPError?

@coveralls
Copy link

coveralls commented Jul 10, 2020

Coverage Status

Coverage remained the same at 97.096% when pulling b2ef8f1 on ali/fix_error_handling into 3e0fa0a on master.

@aliabbasrizvi aliabbasrizvi removed their assignment Jul 10, 2020
@aliabbasrizvi aliabbasrizvi requested a review from a team July 10, 2020 17:39
Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@aliabbasrizvi
Copy link
Contributor Author

Tests had passed: https://travis-ci.org/github/optimizely/python-sdk/builds/706967427. Going to force merge.

@mikeproeng37
Copy link
Contributor

Go for it! Travis has been misbehaving lately...

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.

3 participants