mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
xdrgen: Report unsupported client-side directives without a traceback
The struct and union emitters raise NotImplementedError when a "pragma pages" or "pragma aggregate" member is generated for the client peer. The source subcommand catches the parse and semantic errors but not that one, so a client generation request for such a specification emits partial output and then a Python traceback, which buries the one line that says what is unsupported. Catch the exception in the source subcommand and report its message on stderr the way the other diagnostics are reported. Signed-off-by: Chuck Lever <cel@kernel.org>
This commit is contained in:
parent
aa41b1bc75
commit
f10ffc2433
|
|
@ -5,6 +5,7 @@
|
|||
can be compiled for the Linux kernel."""
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from argparse import Namespace
|
||||
from lark import logger
|
||||
|
|
@ -126,12 +127,16 @@ def subcmd(args: Namespace) -> int:
|
|||
except XdrSemanticError as e:
|
||||
handle_semantic_error(e, source, args.filename)
|
||||
return 1
|
||||
match args.peer:
|
||||
case "server":
|
||||
generate_server_source(args.filename, ast, args.language)
|
||||
case "client":
|
||||
generate_client_source(args.filename, ast, args.language)
|
||||
case _:
|
||||
print("Code generation for", args.peer, "is not yet supported")
|
||||
try:
|
||||
match args.peer:
|
||||
case "server":
|
||||
generate_server_source(args.filename, ast, args.language)
|
||||
case "client":
|
||||
generate_client_source(args.filename, ast, args.language)
|
||||
case _:
|
||||
print("Code generation for", args.peer, "is not yet supported")
|
||||
except NotImplementedError as e:
|
||||
sys.stderr.write(f"{args.filename}: {e}\n")
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user