Skip to content

Commit 8272fce

Browse files
committed
Broadened file read error handling in data.json_is_valid()
1 parent 63284bd commit 8272fce

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

  • remove-json-keys/src/remove_json_keys/lib/data
  • translate-messages/src/translate_messages/lib/data

remove-json-keys/src/remove_json_keys/lib/data/json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def is_valid(file_path, format='json'):
1010
if not file_path.exists():
1111
return False
1212
try : file_text = file_path.read_text(encoding='utf-8')
13-
except UnicodeDecodeError:
13+
except Exception:
1414
return False
1515
if format == 'json':
1616
try : json.loads(file_text) ; return True

translate-messages/src/translate_messages/lib/data/json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def is_valid(file_path, format='json'):
88
if not file_path.exists():
99
return False
1010
try : file_text = file_path.read_text(encoding='utf-8')
11-
except UnicodeDecodeError:
11+
except Exception:
1212
return False
1313
if format == 'json':
1414
try : json.loads(file_text) ; return True

0 commit comments

Comments
 (0)