diff options
Diffstat (limited to 'cfgv.py')
-rw-r--r-- | cfgv.py | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -395,11 +395,14 @@ def load_from_filename( if not os.path.exists(filename): raise ValidationError(f'{filename} does not exist') - with open(filename, encoding='utf-8') as f: - contents = f.read() - with validate_context(f'File {filename}'): try: + with open(filename, encoding='utf-8') as f: + contents = f.read() + except UnicodeDecodeError as e: + raise ValidationError(str(e)) + + try: data = load_strategy(contents) except Exception as e: raise ValidationError(str(e)) |