1 #ifndef BABELTRACE_ERROR_INTERNAL_H
2 #define BABELTRACE_ERROR_INTERNAL_H
5 * Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 #include <babeltrace2/babeltrace.h>
29 #include "lib/object.h"
30 #include "common/macros.h"
32 struct bt_error_cause
{
33 enum bt_error_cause_actor_type actor_type
;
40 struct bt_error_cause_component_class_id
{
42 bt_component_class_type type
;
46 struct bt_error_cause_component_actor
{
47 struct bt_error_cause base
;
49 struct bt_error_cause_component_class_id comp_class_id
;
52 struct bt_error_cause_component_class_actor
{
53 struct bt_error_cause base
;
54 struct bt_error_cause_component_class_id comp_class_id
;
57 struct bt_error_cause_message_iterator_actor
{
58 struct bt_error_cause base
;
60 GString
*output_port_name
;
61 struct bt_error_cause_component_class_id comp_class_id
;
66 * Array of `struct bt_error_cause *` (or an extension); owned
73 const char *bt_error_cause_actor_type_string(
74 enum bt_error_cause_actor_type actor_type
)
77 case BT_ERROR_CAUSE_ACTOR_TYPE_UNKNOWN
:
79 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT
:
81 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS
:
82 return "COMPONENT_CLASS";
83 case BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
:
84 return "MESSAGE_ITERATOR";
91 struct bt_error
*bt_error_create(void);
94 void bt_error_destroy(struct bt_error
*error
);
97 int bt_error_append_cause_from_unknown(struct bt_error
*error
,
98 const char *module_name
, const char *file_name
,
99 uint64_t line_no
, const char *msg_fmt
, va_list args
);
102 int bt_error_append_cause_from_component(
103 struct bt_error
*error
, bt_self_component
*self_comp
,
104 const char *file_name
, uint64_t line_no
,
105 const char *msg_fmt
, va_list args
);
108 int bt_error_append_cause_from_component_class(
109 struct bt_error
*error
,
110 bt_self_component_class
*self_comp_class
,
111 const char *file_name
, uint64_t line_no
,
112 const char *msg_fmt
, va_list args
);
115 int bt_error_append_cause_from_message_iterator(
116 struct bt_error
*error
, bt_self_message_iterator
*self_iter
,
117 const char *file_name
, uint64_t line_no
,
118 const char *msg_fmt
, va_list args
);
120 #endif /* BABELTRACE_ERROR_INTERNAL_H */