Skip to content

Commit 3a02d4e

Browse files
committed
Catch invalid JSON file errors
1 parent 3421936 commit 3a02d4e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

RemoveWindowsLockScreenAds/RemoveWindowsLockScreenAds.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ def remove_ads_file(self, path):
8282

8383
logger.debug("Processing ContentDeliveryManager file: {}".format(os.path.basename(path)))
8484

85-
with open(path, 'r', encoding='utf-8') as f:
86-
jso = json.load(f)
85+
try:
86+
with open(path, 'r', encoding='utf-8') as f:
87+
jso = json.load(f)
88+
except json.decoder.JSONDecodeError:
89+
logger.error(f"Invalid JSON file: {path}")
90+
return None
8791

8892
# Iterate list of items and pick the ones we want to keep
8993
keep_items = []

0 commit comments

Comments
 (0)