summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ee2cad2)
If bt_bt2_graph_add_port_added_listener or
bt_bt2_graph_add_ports_connected_listener fail, it can be either because
one of the calls to the Babeltrace API fails or a Python object creation
fails. On the Python side, we raise a bt2.Error on failure. This seems
fine, although in a subsequent patch, it will become a pre-condition for
raising bt2.Error that we have an error set for the current thread.
Add some calls to BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN in
the errors paths of these wrappers that don't come from the library,
i.e. on which there would not already be an error cause appended.
On the Python side, use bt2.Error directly instead of
utils._raise_bt2_error. Since these were the last call sites of
utils._raise_bt2_error, remove it.
Change-Id: I1556b626a941e9cc127fb036d6e3b9b6346fde88
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1745
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
listener_ids = fn(self._ptr, listener_from_native)
if listener_ids is None:
listener_ids = fn(self._ptr, listener_from_native)
if listener_ids is None:
- utils._raise_bt2_error('cannot add listener to graph object')
+ raise bt2.Error('cannot add listener to graph object')
+
return bt2._ListenerHandle(listener_ids, self)
def add_ports_connected_listener(self, listener):
return bt2._ListenerHandle(listener_ids, self)
def add_ports_connected_listener(self, listener):
listener_ids = fn(self._ptr, listener_from_native)
if listener_ids is None:
listener_ids = fn(self._ptr, listener_from_native)
if listener_ids is None:
- utils._raise_bt2_error('cannot add listener to graph object')
+ raise bt2.Error('cannot add listener to graph object')
+
return bt2._ListenerHandle(listener_ids, self)
def run(self):
return bt2._ListenerHandle(listener_ids, self)
def run(self):
PyObject *py_listener_id = NULL;
int listener_id;
bt_graph_add_listener_status status;
PyObject *py_listener_id = NULL;
int listener_id;
bt_graph_add_listener_status status;
+ const char * const module_name =
+ "graph_add_port_added_listener() (Python)";
BT_ASSERT(graph);
BT_ASSERT(py_callable);
BT_ASSERT(graph);
BT_ASSERT(py_callable);
*/
py_listener_ids = PyTuple_New(4);
if (!py_listener_ids) {
*/
py_listener_ids = PyTuple_New(4);
if (!py_listener_ids) {
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
+ "Failed to allocate one PyTuple.");
graph, source_component_output_port_added_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
graph, source_component_output_port_added_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
+ /*
+ * bt_graph_add_source_component_output_port_added_listener has
+ * already logged/appended an error cause.
+ */
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
+ "Failed to allocate one PyLong.");
graph, filter_component_input_port_added_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
graph, filter_component_input_port_added_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
+ /*
+ * bt_graph_add_filter_component_input_port_added_listener has
+ * already logged/appended an error cause.
+ */
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
+ "Failed to allocate one PyLong.");
graph, filter_component_output_port_added_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
graph, filter_component_output_port_added_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
+ /*
+ * bt_graph_add_filter_component_output_port_added_listener has
+ * already logged/appended an error cause.
+ */
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
+ "Failed to allocate one PyLong.");
graph, sink_component_input_port_added_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
graph, sink_component_input_port_added_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
+ /*
+ * bt_graph_add_sink_component_input_port_added_listener has
+ * already logged/appended an error cause.
+ */
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
+ "Failed to allocate one PyLong.");
PyObject *py_listener_id = NULL;
int listener_id;
bt_graph_add_listener_status status;
PyObject *py_listener_id = NULL;
int listener_id;
bt_graph_add_listener_status status;
+ const char * const module_name =
+ "graph_add_ports_connected_listener() (Python)";
BT_ASSERT(graph);
BT_ASSERT(py_callable);
BT_ASSERT(graph);
BT_ASSERT(py_callable);
* return all of their ids. */
py_listener_ids = PyTuple_New(4);
if (!py_listener_ids) {
* return all of their ids. */
py_listener_ids = PyTuple_New(4);
if (!py_listener_ids) {
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
+ "Failed to allocate one PyTuple.");
graph, source_filter_component_ports_connected_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
graph, source_filter_component_ports_connected_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
+ /*
+ * bt_graph_add_source_filter_component_ports_connected_listener
+ * has already logged/appended an error cause.
+ */
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
+ "Failed to allocate one PyLong.");
graph, source_sink_component_ports_connected_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
graph, source_sink_component_ports_connected_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
+ /*
+ * bt_graph_add_source_sink_component_ports_connected_listener
+ * has already logged/appended an error cause.
+ */
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
+ "Failed to allocate one PyLong.");
graph, filter_filter_component_ports_connected_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
graph, filter_filter_component_ports_connected_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
+ /*
+ * bt_graph_add_filter_filter_component_ports_connected_listener
+ * has already logged/appended an error cause.
+ */
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
+ "Failed to allocate one PyLong.");
graph, filter_sink_component_ports_connected_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
graph, filter_sink_component_ports_connected_listener,
graph_listener_removed, py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
+ /*
+ * bt_graph_add_filter_sink_component_ports_connected_listener
+ * has already logged/appended an error cause.
+ */
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
goto error;
}
py_listener_id = PyLong_FromLong(listener_id);
if (!py_listener_id) {
+ BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
+ "Failed to allocate one PyLong.");
raise ValueError('{} is not a power of two'.format(a))
raise ValueError('{} is not a power of two'.format(a))
-def _raise_bt2_error(msg):
- if msg is None:
- raise bt2.Error
- else:
- raise bt2.Error(msg)
-
-
def _check_log_level(log_level):
_check_int(log_level)
def _check_log_level(log_level):
_check_int(log_level)