mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 04:02:32 +01:00
[exception] implement constructing HttpError from response
This commit is contained in:
parent
6d8d882dbf
commit
1023b2d85d
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user