Now that we can have exception contexts that don't specify a specific line, we can use that context to raise errors when opening the file.
If we don't have a parent context, we can simply use our own. Signed-off-by: John Snow <js...@redhat.com> --- scripts/qapi/parser.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index fc0b1516cc..5a7233bc76 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -67,11 +67,13 @@ def __init__(self, fname, previously_included=None, incl_info=None): with open(self._fname, 'r', encoding='utf-8') as fp: self.src = fp.read() except IOError as e: - raise QAPISemError(incl_info or QAPISourceInfo(None), - "can't read %s file '%s': %s" - % ("include" if incl_info else "schema", - self._fname, - e.strerror)) + msg = "can't read {kind:s} file '{fname:s}': {errmsg:s}".format( + kind='include' if incl_info else 'schema', + fname=self._fname, + errmsg=e.strerror + ) + context = incl_info or self.info + raise QAPIParseError(context, msg) from e self._parse() def _parse(self): -- 2.26.2