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/error-const.h>
29 #include <babeltrace2/error-cause-const.h>
30 #include "lib/object.h"
31 #include "common/macros.h"
33 struct bt_error_cause
{
34 enum bt_error_cause_actor_type actor_type
;
41 struct bt_error_cause_component_class_id
{
43 bt_component_class_type type
;
47 struct bt_error_cause_component_actor
{
48 struct bt_error_cause base
;
50 struct bt_error_cause_component_class_id comp_class_id
;
53 struct bt_error_cause_component_class_actor
{
54 struct bt_error_cause base
;
55 struct bt_error_cause_component_class_id comp_class_id
;
58 struct bt_error_cause_message_iterator_actor
{
59 struct bt_error_cause base
;
61 GString
*output_port_name
;
62 struct bt_error_cause_component_class_id comp_class_id
;
67 * Array of `struct bt_error_cause *` (or an extension); owned
74 const char *bt_error_cause_actor_type_string(
75 enum bt_error_cause_actor_type actor_type
)
78 case BT_ERROR_CAUSE_ACTOR_TYPE_UNKNOWN
:
79 return "BT_ERROR_CAUSE_ACTOR_TYPE_UNKNOWN";
80 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT
:
81 return "BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT";
82 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS
:
83 return "BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS";
84 case BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
:
85 return "BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR";
92 struct bt_error
*bt_error_create(void);
95 void bt_error_destroy(struct bt_error
*error
);
98 int bt_error_append_cause_from_unknown(struct bt_error
*error
,
99 const char *module_name
, const char *file_name
,
100 uint64_t line_no
, const char *msg_fmt
, va_list args
);
103 int bt_error_append_cause_from_component(
104 struct bt_error
*error
, bt_self_component
*self_comp
,
105 const char *file_name
, uint64_t line_no
,
106 const char *msg_fmt
, va_list args
);
109 int bt_error_append_cause_from_component_class(
110 struct bt_error
*error
,
111 bt_self_component_class
*self_comp_class
,
112 const char *file_name
, uint64_t line_no
,
113 const char *msg_fmt
, va_list args
);
116 int bt_error_append_cause_from_message_iterator(
117 struct bt_error
*error
, bt_self_message_iterator
*self_iter
,
118 const char *file_name
, uint64_t line_no
,
119 const char *msg_fmt
, va_list args
);
121 #endif /* BABELTRACE_ERROR_INTERNAL_H */