From 11d55fec4f78a73e41c303d280c9899b99d0d034 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Tue, 5 Jun 2018 23:18:56 +0200 Subject: [PATCH] Better OSError handling for YAML parser --- esphomeyaml/yaml_util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphomeyaml/yaml_util.py b/esphomeyaml/yaml_util.py index a18bd7ce9d..c7c85cbc8a 100644 --- a/esphomeyaml/yaml_util.py +++ b/esphomeyaml/yaml_util.py @@ -48,8 +48,9 @@ def load_yaml(fname): with codecs.open(fname, encoding='utf-8') as conf_file: return yaml.load(conf_file, Loader=SafeLineLoader) or OrderedDict() except yaml.YAMLError as exc: - _LOGGER.error(exc) raise ESPHomeYAMLError(exc) + except IOError as exc: + raise ESPHomeYAMLError(u"Error accessing file {}: {}".format(fname, exc)) except UnicodeDecodeError as exc: _LOGGER.error(u"Unable to read file %s: %s", fname, exc) raise ESPHomeYAMLError(exc)