diff --git a/question.py b/question.py index 358ff80..cf16053 100644 --- a/question.py +++ b/question.py @@ -109,7 +109,11 @@ class Questions(object): self._gen_error(filename, "Section element %d is not a string (type %s found)" % (n, type(sec_filename))) fpath = os.path.join(basedir, sec_filename) - sec_ysrc = self._get_yaml(fpath) + sec_ysrc = None + try: + sec_ysrc = self._get_yaml(fpath) + except (OSError, IOError) as e: + raise QuestionException("Error reading question file %s: %s" % (fpath, str(e))) self._read_sections(sec_ysrc, fpath) def _read_sections(self, ysrc, filename):