Part of the goal of v0.3.0 is to cover over the requests API so it’s easier to swap it out. While requests objects are no longer involved in method calls or return values, we still surface exceptions from requests in a few spots:
WaybackSession.request() and WaybackSession.send() can raise exceptions from requests pertaining to network failures. Generally these are actually urllib3 exceptions that requests wraps, and we could do similarly.
The last one is the one I'm most concerned about. It's not great that network errors come from an underlying framework that might change, but not the worst thing in the world. However, we should never explicitly raise that kind of error ourselves. Instead this should be a WaybackException or a MementoPlaybackError.
Additionally, there’s a special case we are not handling above: if the status is 404 on a non-memento, that means the URL has never been archived by the Wayback Machine, and we should raise a special exception for that case.
Part of the goal of v0.3.0 is to cover over the
requests
API so it’s easier to swap it out. While requests objects are no longer involved in method calls or return values, we still surface exceptions from requests in a few spots:WaybackSession.request()
andWaybackSession.send()
can raise exceptions from requests pertaining to network failures. Generally these are actually urllib3 exceptions that requests wraps, and we could do similarly.WaybackClient.search()
can raise when it callsWaybackSession.request()
as above. https://github.com/edgi-govdata-archiving/wayback/blob/7e9bccc8113e2a24090d3c51b1ae463871da8181/wayback/_client.py#L482-L483WaybackClient.get_memento()
can raise when it callsWaybackSession.request()
as above.https://github.com/edgi-govdata-archiving/wayback/blob/7e9bccc8113e2a24090d3c51b1ae463871da8181/wayback/_client.py#L711
And
WaybackSession.send()
as above.https://github.com/edgi-govdata-archiving/wayback/blob/7e9bccc8113e2a24090d3c51b1ae463871da8181/wayback/_client.py#L806
WaybackClient.get_memento()
can raise when it encounters a non-memento response with a 400+ status code:https://github.com/edgi-govdata-archiving/wayback/blob/7e9bccc8113e2a24090d3c51b1ae463871da8181/wayback/_client.py#L772-L790
The last one is the one I'm most concerned about. It's not great that network errors come from an underlying framework that might change, but not the worst thing in the world. However, we should never explicitly raise that kind of error ourselves. Instead this should be a
WaybackException
or aMementoPlaybackError
.Additionally, there’s a special case we are not handling above: if the status is 404 on a non-memento, that means the URL has never been archived by the Wayback Machine, and we should raise a special exception for that case.