From e461c0b819174181795e0ac5d25b3041ae6e7f61 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 17 Aug 2022 13:25:08 +0200 Subject: [PATCH] Playwright fetcher didn't report low level HTTP errors correctly (like Connection Refused) (#852) --- changedetectionio/content_fetcher.py | 5 +++-- changedetectionio/update_worker.py | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index 049cd18a..49baf72f 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -31,11 +31,12 @@ class JSActionExceptions(Exception): return class PageUnloadable(Exception): - def __init__(self, status_code, url, screenshot=False): + def __init__(self, status_code, url, screenshot=False, message=False): # Set this so we can use it in other parts of the app self.status_code = status_code self.url = url self.screenshot = screenshot + self.message = message return class EmptyReply(Exception): @@ -356,7 +357,7 @@ class base_html_playwright(Fetcher): print(str(e)) context.close() browser.close() - raise PageUnloadable(url=url, status_code=None) + raise PageUnloadable(url=url, status_code=None, message=e.message) if response is None: context.close() diff --git a/changedetectionio/update_worker.py b/changedetectionio/update_worker.py index 0f9758d2..a1a8c90b 100644 --- a/changedetectionio/update_worker.py +++ b/changedetectionio/update_worker.py @@ -222,8 +222,10 @@ class update_worker(threading.Thread): self.datastore.update_watch(uuid=uuid, update_obj={'last_error': err_text, 'last_check_status': e.status_code}) except content_fetcher.PageUnloadable as e: - # @todo connection-refused ? err_text = "Page request from server didnt respond correctly" + if e.message: + err_text = "{} - {}".format(err_text, e.message) + if e.screenshot: self.datastore.save_screenshot(watch_uuid=uuid, screenshot=e.screenshot, as_error=True)