[common] introduce 'status' attribute to Extractors

allows reporting error codes for exceptions that are not handled
by the Job.run() try-except block

- fixes Job.status being 0 in certain situations even when errors occurred
- fixes some URLs not getting written to -e/--error-file (#7758)
This commit is contained in:
Mike Fährmann
2025-07-05 21:19:48 +02:00
parent d349c248c0
commit 1bbacba4ed
3 changed files with 9 additions and 3 deletions

View File

@@ -36,6 +36,7 @@ class Extractor():
directory_fmt = ("{category}",)
filename_fmt = "{filename}.{extension}"
archive_fmt = ""
status = 0
root = ""
cookies_domain = ""
cookies_index = 0
@@ -207,6 +208,7 @@ class Extractor():
response.encoding = encoding
return response
if notfound and code == 404:
self.status |= exception.NotFoundError.code
raise exception.NotFoundError(notfound)
msg = f"'{code} {response.reason}' for '{response.url}'"
@@ -246,6 +248,8 @@ class Extractor():
if not fatal or fatal is ...:
self.log.warning(msg)
return util.NullResponse(url, msg)
self.status |= exception.HttpError.code
raise exception.HttpError(msg, response)
def request_location(self, url, **kwargs):