From 9860896d20254a8c07ac2f9dd82195268a30e311 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Mon, 17 Aug 2015 00:19:32 +0200 Subject: [PATCH] Better error message on "file not found" --- question.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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):