[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 04/25] qapi: Prefix frontend errors with an "in definition" l
From: |
Eric Blake |
Subject: |
Re: [PATCH 04/25] qapi: Prefix frontend errors with an "in definition" line |
Date: |
Tue, 24 Sep 2019 09:58:17 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
On 9/24/19 8:28 AM, Markus Armbruster wrote:
> We take pains to include the offending expression in error messages,
> e.g.
>
> tests/qapi-schema/alternate-any.json:2: alternate 'Alt' member 'one'
> cannot use type 'any'
>
> But not always:
>
> tests/qapi-schema/enum-if-invalid.json:2: 'if' condition must be a string
> or a list of strings
>
> Instead of improving them one by one, report the offending expression
> whenever it is known, like this:
>
> tests/qapi-schema/enum-if-invalid.json: In enum 'TestIfEnum':
> tests/qapi-schema/enum-if-invalid.json:2: 'if' condition must be a string
> or a list of strings
Works for me.
>
> Error messages that mention the offending expression become a bit
> redundant, e.g.
>
> tests/qapi-schema/alternate-any.json: In alternate 'Alt':
> tests/qapi-schema/alternate-any.json:2: alternate 'Alt' member 'one'
> cannot use type 'any'
>
> I'll take care of that later in this series.
Temporary verboseness is not a problem.
>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> scripts/qapi/common.py | 15 ++++++++++++++-
> tests/qapi-schema/alternate-any.err | 1 +
> tests/qapi-schema/alternate-array.err | 1 +
Touches a lot. But such is refactoring life.
> +++ b/scripts/qapi/common.py
> @@ -64,6 +64,12 @@ class QAPISourceInfo(object):
> self.fname = fname
> self.line = line
> self.parent = parent
> + self.defn_meta = None
> + self.defn_name = None
> +
> + def set_defn(self, meta, name):
> + self.defn_meta = meta
> + self.defn_name = name
>
> def next_line(self):
> info = copy.copy(self)
> @@ -73,6 +79,12 @@ class QAPISourceInfo(object):
> def loc(self):
> return '%s:%d' % (self.fname, self.line)
>
> + def in_defn(self):
> + if self.defn_name:
> + return "%s: In %s '%s':\n" % (self.fname,
> + self.defn_meta, self.defn_name)
> + return ''
> +
> def include_path(self):
> ret = ''
> parent = self.parent
> @@ -82,7 +94,7 @@ class QAPISourceInfo(object):
> return ret
>
> def __str__(self):
> - return self.include_path() + self.loc()
> + return self.include_path() + self.in_defn() + self.loc()
>
>
> class QAPIError(Exception):
> @@ -1127,6 +1139,7 @@ def check_exprs(exprs):
> normalize_if(expr)
> name = expr[meta]
> add_name(name, info, meta)
> + info.set_defn(meta, name)
> if doc and doc.symbol != name:
Rather simple addition. Everything else in the patch is fallout.
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- [PATCH 09/25] qapi: Improve reporting of invalid name errors, (continued)
- [PATCH 09/25] qapi: Improve reporting of invalid name errors, Markus Armbruster, 2019/09/24
- [PATCH 25/25] qapi: Improve source file read error handling, Markus Armbruster, 2019/09/24
- [PATCH 08/25] qapi: Reorder check_FOO() parameters for consistency, Markus Armbruster, 2019/09/24
- [PATCH 14/25] qapi: Plumb info to the QAPISchemaMember, Markus Armbruster, 2019/09/24
- [PATCH 04/25] qapi: Prefix frontend errors with an "in definition" line, Markus Armbruster, 2019/09/24
- Re: [PATCH 04/25] qapi: Prefix frontend errors with an "in definition" line,
Eric Blake <=
- [PATCH 21/25] qapi: Avoid redundant definition references in error messages, Markus Armbruster, 2019/09/24
- [PATCH 06/25] qapi: Change frontend error messages to start with lower case, Markus Armbruster, 2019/09/24
- [PATCH 16/25] qapi: Move context-sensitive checking to the proper place, Markus Armbruster, 2019/09/24