linux-stable/tools/net/ynl/lib
Jakub Kicinski ebe3bdc435 tools: ynl: throw a more meaningful exception if family not supported
cli.py currently throws a pure KeyError if kernel doesn't support
a netlink family. Users who did not write ynl (hah) may waste
their time investigating what's wrong with the Python code.
Improve the error message:

Traceback (most recent call last):
  File "/home/kicinski/devel/linux/tools/net/ynl/lib/ynl.py", line 362, in __init__
    self.family = GenlFamily(self.yaml['name'])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kicinski/devel/linux/tools/net/ynl/lib/ynl.py", line 331, in __init__
    self.genl_family = genl_family_name_to_id[family_name]
                       ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'netdev'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kicinski/devel/linux/./tools/net/ynl/cli.py", line 52, in <module>
    main()
  File "/home/kicinski/devel/linux/./tools/net/ynl/cli.py", line 31, in main
    ynl = YnlFamily(args.spec, args.schema)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kicinski/devel/linux/tools/net/ynl/lib/ynl.py", line 364, in __init__
    raise Exception(f"Family '{self.yaml['name']}' not supported by the kernel")
Exception: Family 'netdev' not supported by the kernel

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/20230407145609.297525-1-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-04-11 15:33:46 +02:00
..
.gitignore tools: net: add __pycache__ to gitignore 2023-02-24 11:55:47 -08:00
__init__.py tools: ynl: move the enum classes to shared code 2023-03-08 23:28:21 -08:00
nlspec.py tools: ynl: ethtool testing tool 2023-03-30 23:29:57 -07:00
ynl.py tools: ynl: throw a more meaningful exception if family not supported 2023-04-11 15:33:46 +02:00