Commit | Line | Data |
---|---|---|
5038e256 | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
5038e256 SM |
3 | * |
4 | * Copyright (c) 2019 Efficios, Inc. | |
5038e256 SM |
5 | */ |
6 | ||
ae2be88d SM |
7 | #ifndef BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_ERROR_I_H |
8 | #define BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_ERROR_I_H | |
9 | ||
5038e256 SM |
10 | #include <string-format/format-error.h> |
11 | ||
12 | static | |
13 | PyObject *bt_bt2_format_bt_error_cause(const bt_error_cause *error_cause) | |
14 | { | |
15 | gchar *error_cause_str; | |
16 | PyObject *py_error_cause_str = NULL; | |
17 | ||
18 | error_cause_str = format_bt_error_cause(error_cause, 80, | |
71436ae4 SM |
19 | (bt_logging_level) bt_python_bindings_bt2_log_level, |
20 | BT_COMMON_COLOR_WHEN_NEVER); | |
5038e256 SM |
21 | BT_ASSERT(error_cause_str); |
22 | ||
23 | py_error_cause_str = PyString_FromString(error_cause_str); | |
24 | ||
25 | g_free(error_cause_str); | |
26 | ||
27 | return py_error_cause_str; | |
28 | } | |
29 | ||
30 | static | |
31 | PyObject *bt_bt2_format_bt_error(const bt_error *error) | |
32 | { | |
33 | gchar *error_str; | |
34 | PyObject *py_error_str = NULL; | |
35 | ||
36 | error_str = format_bt_error(error, 80, | |
71436ae4 SM |
37 | (bt_logging_level) bt_python_bindings_bt2_log_level, |
38 | BT_COMMON_COLOR_WHEN_NEVER); | |
5038e256 SM |
39 | BT_ASSERT(error_str); |
40 | ||
41 | py_error_str = PyString_FromString(error_str); | |
42 | ||
43 | g_free(error_str); | |
44 | ||
45 | return py_error_str; | |
46 | } | |
ae2be88d SM |
47 | |
48 | #endif /* BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_ERROR_I_H */ |