| 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_python_bindings_bt2_log_level, BT_COMMON_COLOR_WHEN_NEVER); |
| 17 | BT_ASSERT(error_cause_str); |
| 18 | |
| 19 | py_error_cause_str = PyString_FromString(error_cause_str); |
| 20 | |
| 21 | g_free(error_cause_str); |
| 22 | |
| 23 | return py_error_cause_str; |
| 24 | } |
| 25 | |
| 26 | static |
| 27 | PyObject *bt_bt2_format_bt_error(const bt_error *error) |
| 28 | { |
| 29 | gchar *error_str; |
| 30 | PyObject *py_error_str = NULL; |
| 31 | |
| 32 | error_str = format_bt_error(error, 80, |
| 33 | bt_python_bindings_bt2_log_level, BT_COMMON_COLOR_WHEN_NEVER); |
| 34 | BT_ASSERT(error_str); |
| 35 | |
| 36 | py_error_str = PyString_FromString(error_str); |
| 37 | |
| 38 | g_free(error_str); |
| 39 | |
| 40 | return py_error_str; |
| 41 | } |