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
1 changed files with 4 additions and 3 deletions

View File

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