Skip to content

External lib errors wrapping #194

Open

Description

@velykanov

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions