forked from moritz/alakazam
catch exception if config file can't be read
This commit is contained in:
@ -70,8 +70,13 @@ def read_config(configpath: str) -> Dict[str, Any]:
|
||||
return {}
|
||||
yaml = YAML(typ='safe', pure=True) # Set type to 'safe' and use pure Python mode
|
||||
yaml.Constructor = MySafeConstructor
|
||||
with open(filepath) as file:
|
||||
yaml_config = yaml.load(file)
|
||||
with open(filepath) as file:
|
||||
try:
|
||||
yaml_config = yaml.load(file)
|
||||
except:
|
||||
logging.error(f"Error reading config file {filepath}")
|
||||
return {}
|
||||
|
||||
if not yaml_config:
|
||||
logging.warning(f"config file {filepath} is empty")
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user