bt2: print actual and expected lengths in _StaticArrayField._set_value error message
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 24 Sep 2019 18:38:51 +0000 (14:38 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 3 Oct 2019 14:45:11 +0000 (10:45 -0400)
I think it can help the user figure out what's wrong if we give the
lengths of the field and the passed value in the error message.

Change-Id: I94fb7ca04724d5d7af701df88aaedc195b1736fd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2088
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/bindings/python/bt2/bt2/field.py

index fbe609eedb473377a3a16ff55ac4091540626bc0..275d500d6fdd4c11e7a4456b602249c788cb89d3 100644 (file)
@@ -855,7 +855,11 @@ class _StaticArrayField(_StaticArrayFieldConst, _ArrayField, _Field):
 
     def _set_value(self, values):
         if len(self) != len(values):
-            raise ValueError('expected length of value and array field to match')
+            raise ValueError(
+                'expected length of value ({}) and array field ({}) to match'.format(
+                    len(values), len(self)
+                )
+            )
 
         for index, value in enumerate(values):
             if value is not None:
This page took 0.026352 seconds and 4 git commands to generate.