mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-31 22:33:53 -06:00
qapi: Improve error position for bogus invalid "Returns" section
When something other than a command has a "Returns" section, the error message points to the beginning of the definition comment. Point to the "Returns" section instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240216145841.2099240-7-armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
15333abed9
commit
bf00dc19f3
2 changed files with 8 additions and 4 deletions
|
@ -759,9 +759,13 @@ class QAPIDoc:
|
||||||
self.features[feature.name].connect(feature)
|
self.features[feature.name].connect(feature)
|
||||||
|
|
||||||
def check_expr(self, expr: QAPIExpression) -> None:
|
def check_expr(self, expr: QAPIExpression) -> None:
|
||||||
if self.has_section('Returns') and 'command' not in expr:
|
if 'command' not in expr:
|
||||||
raise QAPISemError(self.info,
|
sec = next((sec for sec in self.sections
|
||||||
"'Returns:' is only valid for commands")
|
if sec.name == 'Returns'),
|
||||||
|
None)
|
||||||
|
if sec:
|
||||||
|
raise QAPISemError(sec.info,
|
||||||
|
"'Returns:' is only valid for commands")
|
||||||
|
|
||||||
def check(self) -> None:
|
def check(self) -> None:
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
doc-invalid-return.json:3: 'Returns:' is only valid for commands
|
doc-invalid-return.json:5: 'Returns:' is only valid for commands
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue