bt2: print error causes in bt2._Error.__str__
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 19 Sep 2019 21:13:58 +0000 (17:13 -0400)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 20 Sep 2019 17:18:10 +0000 (13:18 -0400)
commit8258c4bd94a2ed6e3c23cd6c21c331b75d1ae52b
tree724a85a14e878947a2cbb4d34f01e41dfab8d4d7
parente8cafc6e00a1de000a844a63091b42a0447cb21c
bt2: print error causes in bt2._Error.__str__

When working on Python tests where a bt2._Error escapes the test, I very
often write the same thing to be able to visualize error causes:

    try:
        ... original code ...
    except bt2._Error as e:
        for c in e:
    print(c)
raise

By making bt2._Error.__str__ print the error causes, the causes will be
printed automatically when a test fails this way.

And from the point of view of a user of the bt2 package, I think it's
quite useful to get the error causes right away, rather than having to
write a snippet like the above.  As a user of the library, if a
bt2._Error escapes or if I print it, I'd be happy to get this very
precise information.  Also, not everyone might know from the start that
it's possible to print detailed causes, and the otherwise default
message is rather vague.  It just says for example "Failed to add
component to graph", without any other detail.  So I think we would do
users a service by printing the causes by default.

Change-Id: I6f8c72b8e358d6e664c47a1a43c9a81c91a76239
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2070
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/bindings/python/bt2/bt2/error.py
tests/bindings/python/bt2/test_error.py
This page took 0.025741 seconds and 4 git commands to generate.