Skip to contentSkip to conversation

qapi: Improve error message for description following section

PATCH In review Markus Armbruster 2 participants 2 messages May 10, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qapi: Improve error message for description following section

The error message is bad when the section is untagged. For instance, test case doc-interleaved-section produces "'@foobar:' can't follow 'Note' section", which is okay, but if we drop the "Note:" tag, we get "'@foobar:' can't follow 'None' section, which is bad.

Change the error message to "description of '@foobar:' follows a section".

---
 scripts/qapi/parser.py                        | 4 ++--
 tests/qapi-schema/doc-interleaved-section.err | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
scripts/qapi/parser.py +2 -2
index 878f90b458..3de467493f 100644
@@ -700,8 +700,8 @@ def _append_various_line(self, line: str) -> None:
 
         if name.startswith('@') and name.endswith(':'):
             raise QAPIParseError(self._parser,
-                                 "'%s' can't follow '%s' section"
-                                 % (name, self.sections[0].name))
+                                 "description of '%s' follows a section"
+                                 % name)
         if self._is_section_tag(name):
             # If line is "Section:   first line of description", find
             # the index of 'f', which is the indent we expect for any
tests/qapi-schema/doc-interleaved-section.err +1 -1
index 715d58cd31..e5d1ef54c1 100644
@@ -1 +1 @@
-doc-interleaved-section.json:15:1: '@foobar:' can't follow 'Note' section
+doc-interleaved-section.json:15:1: description of '@foobar:' follows a section
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Markus Armbruster

The error message is bad when the section is untagged. For instance, test case doc-interleaved-section produces "'@foobar:' can't follow 'Note' section", which is okay, but if we drop the "Note:" tag, we get "'@foobar:' can't follow 'None' section, which is bad.

Change the error message to "description of '@foobar:' follows a section".