From eca782c0be747de53896807bf7ede1011931d7e8 Mon Sep 17 00:00:00 2001 From: Jeppy Date: Mon, 7 Nov 2022 17:34:10 +0100 Subject: [PATCH] CHANGE assertion to ValueError --- kleinanzeigen_bot/extract.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kleinanzeigen_bot/extract.py b/kleinanzeigen_bot/extract.py index 79c7d74..376d680 100644 --- a/kleinanzeigen_bot/extract.py +++ b/kleinanzeigen_bot/extract.py @@ -45,7 +45,11 @@ class AdExtractor: belen_conf = self.driver.execute_script("return window.BelenConf") special_attributes_str = belen_conf["universalAnalyticsOpts"]["dimensions"]["dimension108"] special_attributes = json.loads(special_attributes_str) - assert isinstance(special_attributes, dict) + if not isinstance(special_attributes, dict): + raise ValueError( + "Failed to parse special attributes from ad page." + f"Expected a dictionary, but got a {type(special_attributes)}" + ) special_attributes = {k: v for k, v in special_attributes.items() if not k.endswith('.versand_s')} return special_attributes