bt2: report errors from Python component and component class callbacks
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 12 Jul 2019 04:45:38 +0000 (00:45 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 18 Jul 2019 15:53:36 +0000 (11:53 -0400)
commitf8d71b5929dc15eae46f38bd0d954e847c804145
treea670fe9f7ea49c17a16e2001d7822a21932ad25b
parent8a08af82fd9df23f0c13fb9a872947d2a30a911c
bt2: report errors from Python component and component class callbacks

This patchs makes the Python bindings report errors when the user Python
code raises an exception which results in the status code ERROR.  The
result looks like this:

    ERROR:    [Babeltrace CLI] (/home/smarchi/src/babeltrace/src/cli/babeltrace2.c:2534)
      Cannot create components.
    CAUSED BY [Babeltrace CLI] (/home/smarchi/src/babeltrace/src/cli/babeltrace2.c:2357)
      Cannot create component: plugin-name="gpx", comp-cls-name="GpxSource", comp-cls-type=0, comp-name="source.gpx.GpxSource"
    CAUSED BY [Babeltrace library] (/home/smarchi/src/babeltrace/src/lib/graph/graph.c:1337)
      Component initialization method failed: status=ERROR, comp-addr=0x55d020aeb8b0, comp-name="source.gpx.GpxSource", comp-log-level=BT_LOGGING_LEVEL_WARNING, comp-class-type=BT_COMPONENT_CLASS_TYPE_SOURCE,
      comp-class-name="GpxSource", comp-class-partial-descr="", comp-class-is-frozen=0, comp-input-port-count=0, comp-output-port-count=0
    CAUSED BY [source.gpx.GpxSource: 'source.gpx.GpxSource'] (bt2/native_bt_wrap.c:3863)
      Traceback (most recent call last):
        File "/home/smarchi/build/babeltrace/src/bindings/python/bt2/build/build_lib/bt2/component.py", line 474, in _bt_init_from_native
          self.__init__(params)
        File "/home/smarchi/src/babeltrace-fun-plugins/gpx/bt_plugin_gpx.py", line 83, in __init__
          raise ValueError("GpxSource: missing `inputs` parameter")
      ValueError: GpxSource: missing `inputs` parameter

Only the callbacks in the component and component classes area are done.
The other ones I see that could use this feature are the graph's port
added and connected callbacks.  However, I can't really test this yet,
because it's not possible to access error causes from Python yet.  They
will be done once we add support for that.

Change-Id: Ic7a2a97831cbfba34730a4e68ada24e06d9fa8f3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1699
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
include/babeltrace2/graph/self-component-class-filter.h
include/babeltrace2/graph/self-component-class-sink.h
include/babeltrace2/graph/self-component-class-source.h
src/bindings/python/bt2/bt2/native_bt_component_class.i
This page took 0.027299 seconds and 4 git commands to generate.