2 * SPDX-License-Identifier: MIT
4 * Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
7 #ifndef BABELTRACE_ERROR_INTERNAL_H
8 #define BABELTRACE_ERROR_INTERNAL_H
12 #include <babeltrace2/babeltrace.h>
13 #include "lib/object.h"
14 #include "common/macros.h"
16 struct bt_error_cause
{
17 enum bt_error_cause_actor_type actor_type
;
24 struct bt_error_cause_component_class_id
{
26 bt_component_class_type type
;
30 struct bt_error_cause_component_actor
{
31 struct bt_error_cause base
;
33 struct bt_error_cause_component_class_id comp_class_id
;
36 struct bt_error_cause_component_class_actor
{
37 struct bt_error_cause base
;
38 struct bt_error_cause_component_class_id comp_class_id
;
41 struct bt_error_cause_message_iterator_actor
{
42 struct bt_error_cause base
;
44 GString
*output_port_name
;
45 struct bt_error_cause_component_class_id comp_class_id
;
50 * Array of `struct bt_error_cause *` (or an extension); owned
57 const char *bt_error_cause_actor_type_string(
58 enum bt_error_cause_actor_type actor_type
)
61 case BT_ERROR_CAUSE_ACTOR_TYPE_UNKNOWN
:
63 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT
:
65 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS
:
66 return "COMPONENT_CLASS";
67 case BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
:
68 return "MESSAGE_ITERATOR";
75 struct bt_error
*bt_error_create(void);
78 void bt_error_destroy(struct bt_error
*error
);
80 BT_HIDDEN
__BT_ATTR_FORMAT_PRINTF(5, 0)
81 int bt_error_append_cause_from_unknown(struct bt_error
*error
,
82 const char *module_name
, const char *file_name
,
83 uint64_t line_no
, const char *msg_fmt
, va_list args
);
85 BT_HIDDEN
__BT_ATTR_FORMAT_PRINTF(5, 0)
86 int bt_error_append_cause_from_component(
87 struct bt_error
*error
, bt_self_component
*self_comp
,
88 const char *file_name
, uint64_t line_no
,
89 const char *msg_fmt
, va_list args
);
91 BT_HIDDEN
__BT_ATTR_FORMAT_PRINTF(5, 0)
92 int bt_error_append_cause_from_component_class(
93 struct bt_error
*error
,
94 bt_self_component_class
*self_comp_class
,
95 const char *file_name
, uint64_t line_no
,
96 const char *msg_fmt
, va_list args
);
98 BT_HIDDEN
__BT_ATTR_FORMAT_PRINTF(5, 0)
99 int bt_error_append_cause_from_message_iterator(
100 struct bt_error
*error
, bt_self_message_iterator
*self_iter
,
101 const char *file_name
, uint64_t line_no
,
102 const char *msg_fmt
, va_list args
);
104 #endif /* BABELTRACE_ERROR_INTERNAL_H */