From f10ffc243355b3921271b3c4060214357128d0bf Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Tue, 8 Sep 2026 11:16:00 -0400 Subject: [PATCH] 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 --- tools/net/sunrpc/xdrgen/subcmds/source.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/net/sunrpc/xdrgen/subcmds/source.py b/tools/net/sunrpc/xdrgen/subcmds/source.py index 56eba34d8eb3..16622cd343c9 100644 --- a/tools/net/sunrpc/xdrgen/subcmds/source.py +++ b/tools/net/sunrpc/xdrgen/subcmds/source.py @@ -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