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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 3 Oct 2019 14:45:10 +0000 (10:45 -0400)
commit9813eca7029e47147014446c0ab6cf841e25472b
treef5bd40286f72375ea507c15324a5eb5c060d2a19
parent7f47aa068c5d4ac1d37bf4f5df6c9320b0d6d3ad
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.024861 seconds and 4 git commands to generate.