Commit b269d2b4 authored by Jakub Kicinski's avatar Jakub Kicinski

tools: ynl: copy netlink error to NlError

Typing e.nl_msg.error when processing exception is a bit tedious
and counter-intuitive. Set a local .error member to the positive
value of the netlink level error.
Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
Link: https://lore.kernel.org/r/20240403023426.1762996-3-kuba@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 1d056bf9
......@@ -100,9 +100,10 @@ class Netlink:
class NlError(Exception):
def __init__(self, nl_msg):
self.nl_msg = nl_msg
self.error = -nl_msg.error
def __str__(self):
return f"Netlink error: {os.strerror(-self.nl_msg.error)}\n{self.nl_msg}"
return f"Netlink error: {os.strerror(self.error)}\n{self.nl_msg}"
class ConfigError(Exception):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment