| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright (c) 2019 Efficios, Inc. |
| 5 | */ |
| 6 | |
| 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 | |
| 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, |
| 19 | (bt_logging_level) bt_python_bindings_bt2_log_level, |
| 20 | BT_COMMON_COLOR_WHEN_NEVER); |
| 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, |
| 37 | (bt_logging_level) bt_python_bindings_bt2_log_level, |
| 38 | BT_COMMON_COLOR_WHEN_NEVER); |
| 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 | } |
| 47 | |
| 48 | #endif /* BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_ERROR_I_H */ |