diff --git a/waybackpy/wrapper.py b/waybackpy/wrapper.py index 3f555f2..06029ce 100644 --- a/waybackpy/wrapper.py +++ b/waybackpy/wrapper.py @@ -51,10 +51,12 @@ def _get_response(req): try: response = urlopen(req) # nosec except Exception as e: - raise WaybackError(e) + exc = WaybackError("Error while retrieving %s" % req.full_ur + ) + exc.__cause__ = e + raise exc return response - class Url: """waybackpy Url object""" @@ -108,19 +110,6 @@ class Url: encoding = "UTF-8" return response.read().decode(encoding.replace("text/html", "UTF-8", 1)) - def get_response(self, req): - """Get response for the supplied request.""" - try: - response = urlopen(req) #nosec - except Exception: - try: - response = urlopen(req) #nosec - except Exception as e: - exc = WaybackError("Error while retrieving %s" % req.full_url) - exc.__cause__ = e - raise exc - return response - def near(self, year=None, month=None, day=None, hour=None, minute=None): """ Return the closest Wayback Machine archive to the time supplied. Supported params are year, month, day, hour and minute.