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

External lib errors wrapping #194

Open
velykanov opened this issue Sep 23, 2019 · 0 comments
Open

External lib errors wrapping #194

velykanov opened this issue Sep 23, 2019 · 0 comments

Comments

@velykanov
Copy link

Hi there!

I've noticed that in this project requests library is used to make queries.
However there is no handling of potential exceptions in external library.

I want you to add some external exceptions wrapping into SparkPostException at least (since I've no access to push into the repo).

The change is pretty simple and would make your code much better, because it's insane when external lib raises errors from another external lib that is used in this one.

My suggestion is something like this (compatible with both Python2.x and Python 3.x):

try:
    response = self.sess.request(method, uri, headers=headers, **kwargs)
except requests.exceptions.RequestException as exc:
    raise SparkPostException(exc)

In case of dropping Python 2.x support from exc part could be added for providing more details about external lib exception.

Thanks a lot and have a nice day!

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

No branches or pull requests

1 participant