lib: handle errors when reading config from file://

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-05 01:03:00 +02:00
parent 1a02049104
commit 86c2a5d69d

View file

@ -87,8 +87,11 @@ class ConfigLoader:
if url.scheme == "env":
value = os.getenv(url.netloc, url.query)
if url.scheme == "file":
with open(url.netloc, "r") as _file:
value = _file.read()
try:
with open(url.netloc, "r") as _file:
value = _file.read()
except OSError:
self._log("error", f"Failed to read config value from {url.netloc}")
return value
def update_from_file(self, path: str):