diff --git a/src/resconfig/io/paths.py b/src/resconfig/io/paths.py index 74f7714..eaf313c 100644 --- a/src/resconfig/io/paths.py +++ b/src/resconfig/io/paths.py @@ -1,3 +1,4 @@ +from logging import getLogger from pathlib import Path from ..typing import FilePath @@ -6,6 +7,8 @@ from . import toml from . import yaml +log = getLogger(__name__) + class ConfigPath(type(Path())): """Path for configuration file.""" @@ -18,7 +21,12 @@ def dump(self, content): def load(self): with open(self) as f: - return self.module.load(f) + try: + content = self.module.load(f) or {} + except Exception: + log.exception("Error occured loading from %s; assume empty...", self) + content = {} + return content @classmethod def from_extension(cls, filename: FilePath) -> "ConfigPath":