From d6a271d2c76430fa0f0cc258dbdc8e9ec223c9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 30 Jul 2020 18:23:26 +0200 Subject: [PATCH] add 'response' objects to 'HttpError's --- gallery_dl/exception.py | 5 +++++ gallery_dl/extractor/common.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gallery_dl/exception.py b/gallery_dl/exception.py index 783e2b21..f553d419 100644 --- a/gallery_dl/exception.py +++ b/gallery_dl/exception.py @@ -51,6 +51,11 @@ class HttpError(ExtractionError): default = "HTTP request failed" code = 4 + def __init__(self, message, response=None): + ExtractionError.__init__(self, message) + self.response = response + self.status = response.status_code if response else 0 + class NotFoundError(ExtractionError): """Requested resource (gallery/image) could not be found""" diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index bbbd8a65..cd7f01ea 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -125,7 +125,7 @@ class Extractor(): time.sleep(min(2 ** (tries-1), 1800)) tries += 1 - raise exception.HttpError(msg) + raise exception.HttpError(msg, response) def wait(self, *, seconds=None, until=None, adjust=1.0, reason="rate limit reset"):