1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-10-26 06:22:32 +02:00

[exception] implement constructing HttpError from response

This commit is contained in:
Mike Fährmann 2024-10-11 19:57:38 +02:00
parent 6d8d882dbf
commit 1023b2d85d
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -54,10 +54,16 @@ class HttpError(ExtractionError):
default = "HTTP request failed"
code = 4
def __init__(self, message, response=None):
ExtractionError.__init__(self, message)
def __init__(self, message="", response=None):
self.response = response
self.status = 0 if response is None else response.status_code
if response is None:
self.status = 0
else:
self.status = response.status_code
if not message:
message = "'{} {}' for '{}'".format(
response.status_code, response.reason, response.url)
ExtractionError.__init__(self, message)
class NotFoundError(ExtractionError):