/* Cancel private definitions */
#undef __BT_FUNC_STATUS_AGAIN
#undef __BT_FUNC_STATUS_END
-#undef __BT_FUNC_STATUS_END
-#undef __BT_FUNC_STATUS_ERROR
#undef __BT_FUNC_STATUS_ERROR
#undef __BT_FUNC_STATUS_INTERRUPTED
#undef __BT_FUNC_STATUS_INVALID_OBJECT
#undef __BT_FUNC_STATUS_MEMORY_ERROR
#undef __BT_FUNC_STATUS_NOT_FOUND
#undef __BT_FUNC_STATUS_OK
+#undef __BT_FUNC_STATUS_OVERFLOW
#undef __BT_IN_BABELTRACE_H
#undef __BT_UPCAST
#undef __BT_UPCAST_CONST
# define __BT_FUNC_STATUS_OVERFLOW -75
#endif
-/* Invalid query parameters */
-#ifndef __BT_FUNC_STATUS_INVALID_PARAMS
-# define __BT_FUNC_STATUS_INVALID_PARAMS -24
-#endif
-
/* Invalid query object */
#ifndef __BT_FUNC_STATUS_INVALID_OBJECT
# define __BT_FUNC_STATUS_INVALID_OBJECT -23
BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_OBJECT = __BT_FUNC_STATUS_INVALID_OBJECT,
- BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS = __BT_FUNC_STATUS_INVALID_PARAMS,
} bt_component_class_query_method_status;
typedef enum bt_component_class_message_iterator_init_method_status {
BT_QUERY_EXECUTOR_QUERY_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
BT_QUERY_EXECUTOR_QUERY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
BT_QUERY_EXECUTOR_QUERY_STATUS_INVALID_OBJECT = __BT_FUNC_STATUS_INVALID_OBJECT,
- BT_QUERY_EXECUTOR_QUERY_STATUS_INVALID_PARAMS = __BT_FUNC_STATUS_INVALID_PARAMS,
} bt_query_executor_query_status;
extern
pass
-class InvalidParams(Exception):
- pass
-
-
class OverflowError(OverflowError):
pass
static PyObject *py_mod_bt2_exc_try_again_type = NULL;
static PyObject *py_mod_bt2_exc_stop_type = NULL;
static PyObject *py_mod_bt2_exc_invalid_object_type = NULL;
-static PyObject *py_mod_bt2_exc_invalid_params_type = NULL;
static
void bt_bt2_cc_init_from_bt2(void)
py_mod_bt2_exc_invalid_object_type =
PyObject_GetAttrString(py_mod_bt2, "InvalidObject");
BT_ASSERT(py_mod_bt2_exc_invalid_object_type);
- py_mod_bt2_exc_invalid_params_type =
- PyObject_GetAttrString(py_mod_bt2, "InvalidParams");
- BT_ASSERT(py_mod_bt2_exc_invalid_params_type);
}
static
Py_XDECREF(py_mod_bt2_exc_try_again_type);
Py_XDECREF(py_mod_bt2_exc_stop_type);
Py_XDECREF(py_mod_bt2_exc_invalid_object_type);
- Py_XDECREF(py_mod_bt2_exc_invalid_params_type);
}
} else if (PyErr_GivenExceptionMatches(exc,
py_mod_bt2_exc_invalid_object_type)) {
status = __BT_FUNC_STATUS_INVALID_OBJECT;
- } else if (PyErr_GivenExceptionMatches(exc,
- py_mod_bt2_exc_invalid_params_type)) {
- status = __BT_FUNC_STATUS_INVALID_PARAMS;
} else {
/* Unknown exception: convert to general error */
log_exception_and_maybe_append_error(BT_LOG_WARNING, true,
raise bt2.InvalidObject
else:
raise bt2.InvalidObject(msg)
- elif status == native_bt.__BT_FUNC_STATUS_INVALID_PARAMS:
- if msg is None:
- raise bt2.InvalidParams
- else:
- raise bt2.InvalidParams(msg)
else:
assert False
case BT_QUERY_EXECUTOR_QUERY_STATUS_INVALID_OBJECT:
*fail_reason = "invalid or unknown query object";
goto error;
- case BT_QUERY_EXECUTOR_QUERY_STATUS_INVALID_PARAMS:
- *fail_reason = "invalid query parameters";
- goto error;
case BT_QUERY_EXECUTOR_QUERY_STATUS_MEMORY_ERROR:
*fail_reason = "not enough memory";
goto error;
switch (status) {
case __BT_FUNC_STATUS_OVERFLOW:
return "OVERFLOW";
- case __BT_FUNC_STATUS_INVALID_PARAMS:
- return "INVALID_PARAMS";
case __BT_FUNC_STATUS_INVALID_OBJECT:
return "INVALID_OBJECT";
case __BT_FUNC_STATUS_MEMORY_ERROR:
#define BT_FUNC_STATUS_ERROR __BT_FUNC_STATUS_ERROR
#define BT_FUNC_STATUS_INTERRUPTED __BT_FUNC_STATUS_INTERRUPTED
#define BT_FUNC_STATUS_INVALID_OBJECT __BT_FUNC_STATUS_INVALID_OBJECT
-#define BT_FUNC_STATUS_INVALID_PARAMS __BT_FUNC_STATUS_INVALID_PARAMS
#define BT_FUNC_STATUS_MEMORY_ERROR __BT_FUNC_STATUS_MEMORY_ERROR
#define BT_FUNC_STATUS_NOT_FOUND __BT_FUNC_STATUS_NOT_FOUND
#define BT_FUNC_STATUS_OK __BT_FUNC_STATUS_OK
"User method returned `BT_FUNC_STATUS_OK` without a result.");
status = (int) query_status;
+ if (status < 0) {
+ BT_LIB_LOGW_APPEND_CAUSE(
+ "Component class's \"query\" method failed: "
+ "query-exec-addr=%p, %![cc-]+C, object=\"%s\", "
+ "%![params-]+v, log-level=%s", query_exec, comp_cls,
+ object, params, bt_common_logging_level_string(log_level));
+ goto end;
+ }
+
end:
return status;
}
if (!bt_value_is_map(params)) {
BT_LOGE_STR("Query parameters is not a map value object.");
- status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS;
+ status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR;
goto error;
}
path_value = bt_value_map_borrow_entry_value_const(params, "path");
if (!path_value) {
BT_LOGE_STR("Mandatory `path` parameter missing");
- status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS;
+ status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR;
goto error;
}
if (!bt_value_is_string(path_value)) {
BT_LOGE_STR("`path` parameter is required to be a string value");
- status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS;
+ status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR;
goto error;
}
if (!bt_value_is_map(params)) {
BT_LOGE("Query parameters is not a map value object.");
- status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS;
+ status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR;
goto error;
}
}
if (!read_src_fs_parameters(params, &inputs_value, ctf_fs)) {
- status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS;
+ status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR;
goto error;
}
url_value = bt_value_map_borrow_entry_value_const(params, URL_PARAM);
if (!url_value) {
- BT_COMP_LOGW("Mandatory `%s` parameter missing", URL_PARAM);
- status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS;
+ BT_COMP_LOGE("Mandatory `%s` parameter missing", URL_PARAM);
+ status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR;
goto error;
}
if (!bt_value_is_string(url_value)) {
- BT_COMP_LOGW("`%s` parameter is required to be a string value",
+ BT_COMP_LOGE("`%s` parameter is required to be a string value",
URL_PARAM);
- status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS;
+ status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR;
goto error;
}
res = bt2.QueryExecutor().query(MySink, 'obj', [17, 23])
exc = ctx.exception
- self.assertEqual(len(exc), 1)
+ self.assertEqual(len(exc), 2)
cause = exc[0]
self.assertIsInstance(cause, bt2.error._ComponentClassErrorCause)
self.assertIn('raise ValueError', cause.message)
with self.assertRaises(ValueError):
res = bt2.QueryExecutor().query(MySink, 'obj', [17, 23], 12345)
- def test_query_invalid_params(self):
- class MySink(bt2._UserSinkComponent):
- def _consume(self):
- pass
-
- def _graph_is_configured(self):
- pass
-
- @classmethod
- def _query(cls, query_exec, obj, params, log_level):
- raise bt2.InvalidParams
-
- with self.assertRaises(bt2.InvalidParams):
- res = bt2.QueryExecutor().query(MySink, 'obj', [17, 23])
-
def test_query_try_again(self):
class MySink(bt2._UserSinkComponent):
def _consume(self):
self._check(trace, -2000000002)
def test_clock_class_offset_s_wrong_type(self):
- with self.assertRaises(bt2.InvalidParams):
+ with self.assertRaises(bt2._Error):
self._executor.query(
self._fs,
'trace-info',
)
def test_clock_class_offset_s_wrong_type_none(self):
- with self.assertRaises(bt2.InvalidParams):
+ with self.assertRaises(bt2._Error):
self._executor.query(
self._fs,
'trace-info',
)
def test_clock_class_offset_ns_wrong_type(self):
- with self.assertRaises(bt2.InvalidParams):
+ with self.assertRaises(bt2._Error):
self._executor.query(
self._fs,
'trace-info',
)
def test_clock_class_offset_ns_wrong_type_none(self):
- with self.assertRaises(bt2.InvalidParams):
+ with self.assertRaises(bt2._Error):
self._executor.query(
self._fs,
'trace-info',