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