Skip to content

Commit

Permalink
Make an obvious error when using BrowserSteps with the simple text fe…
Browse files Browse the repository at this point in the history
…tcher
  • Loading branch information
dgtlmoon committed Jan 31, 2024
1 parent 593660e commit 520650e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions changedetectionio/content_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def __init__(self, status_code, url, message, screenshot=False):
self.message = message
return

class BrowserStepsInUnsupportedFetcher(Exception):
def __init__(self, url):
self.url = url
return

class EmptyReply(Exception):
def __init__(self, status_code, url, screenshot=None):
Expand Down Expand Up @@ -712,6 +716,9 @@ def run(self,
current_include_filters=None,
is_binary=False):

if self.browser_steps_get_valid_steps():
raise BrowserStepsInUnsupportedFetcher(url=url)

# Make requests use a more modern looking user-agent
if not {k.lower(): v for k, v in request_headers.items()}.get('user-agent', None):
request_headers['User-Agent'] = os.getenv("DEFAULT_SETTINGS_HEADERS_USERAGENT",
Expand Down
6 changes: 6 additions & 0 deletions changedetectionio/update_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ def run(self):
'last_check_status': e.status_code,
'has_ldjson_price_data': None})
process_changedetection_results = False
except content_fetcher.BrowserStepsInUnsupportedFetcher as e:
err_text = "This watch has Browser Steps configured and so it cannot run with the 'Basic fast Plaintext/HTTP Client', either remove the Browser Steps or select a Chrome fetcher."
self.datastore.update_watch(uuid=uuid, update_obj={'last_error': err_text})
process_changedetection_results = False
logger.error(f"Exception (BrowserStepsInUnsupportedFetcher) reached processing watch UUID: {uuid}")

except UnableToExtractRestockData as e:
# Usually when fetcher.instock_data returns empty
logger.error(f"Exception (UnableToExtractRestockData) reached processing watch UUID: {uuid}")
Expand Down

0 comments on commit 520650e

Please sign in to comment.