aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKlement Sekera <klement.sekera@gmail.com>2024-03-29 15:04:49 +0100
committerOle Tr�an <otroan@employees.org>2024-06-12 11:55:50 +0000
commit5c0aa7d0b45dea7d19d12e6d7b12965703a9a053 (patch)
treedc06089f6fcfbe02cf08f08a221b8ea2d8e6cf13
parent68b8125dbfc2c5ba7703d8af1c02585fd1263b37 (diff)
papi: more detailed packing error message
'struct.error: required argument is not an integer' is quite useless itself, so let's raise an error from it at least saying what was the thing getting packed Type: improvement Change-Id: Icb762fbab98446d1e1331315e6c337f789cbba95 Signed-off-by: Klement Sekera <klement.sekera@gmail.com>
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_serializer.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py
index d724cb33ce9..707bb03b790 100644
--- a/src/vpp-api/python/vpp_papi/vpp_serializer.py
+++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py
@@ -644,10 +644,15 @@ class VPPType(Packer):
else:
arg = data[a]
kwarg = kwargs[a] if a in kwargs else None
- if isinstance(self.packers[i], VPPType):
- b += self.packers[i].pack(arg, kwarg)
- else:
- b += self.packers[i].pack(arg, kwargs)
+ try:
+ if isinstance(self.packers[i], VPPType):
+ b += self.packers[i].pack(arg, kwarg)
+ else:
+ b += self.packers[i].pack(arg, kwargs)
+ except Exception as e:
+ raise VPPSerializerValueError(
+ f"Exception while packing {data} for {self.name}.{a}."
+ ) from e
return bytes(b)