Exit cleanly in case of non UTF-8 file.

This commit is contained in:
Darko Poljak 2016-08-21 21:48:21 +02:00
parent d9d739cd44
commit b5262c850e

View file

@ -121,9 +121,10 @@ class Config(object):
host = Config.hostfile_process_line(host)
if host:
yield host
except (IOError, OSError) as e:
raise cdist.Error("Error reading hosts from \'{}\'".format(
source))
except (IOError, OSError, UnicodeError) as e:
raise cdist.Error(
"Error reading hosts from file \'{}\': {}".format(
source, e))
else:
if source:
for host in source: