From: Simon Marchi Date: Tue, 24 Sep 2019 18:38:51 +0000 (-0400) Subject: bt2: print actual and expected lengths in _StaticArrayField._set_value error message X-Git-Tag: v2.0.0-rc1~98 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=e5e6a30af8f0ac9dd05710520010b810cd47beb9 bt2: print actual and expected lengths in _StaticArrayField._set_value error message 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 Reviewed-on: https://review.lttng.org/c/babeltrace/+/2088 Reviewed-by: Francis Deslauriers --- diff --git a/src/bindings/python/bt2/bt2/field.py b/src/bindings/python/bt2/bt2/field.py index fbe609ee..275d500d 100644 --- a/src/bindings/python/bt2/bt2/field.py +++ b/src/bindings/python/bt2/bt2/field.py @@ -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: