2 * Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 #define BT_LOG_TAG "LIB/ERROR"
24 #include "lib/logging.h"
28 #include <babeltrace2/error-const.h>
29 #include <babeltrace2/error-cause-const.h>
32 #include "graph/message/iterator.h"
33 #include "graph/component.h"
34 #include "graph/component-class.h"
35 #include "common/assert.h"
36 #include "lib/assert-pre.h"
37 #include "lib/func-status.h"
39 #define BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(_cause, _exp_type) \
40 BT_ASSERT_PRE(((const struct bt_error_cause *) (_cause))->actor_type == _exp_type, \
41 "Unexpected error cause's actor type: type=%s, exp-type=%s", \
42 bt_error_cause_actor_type_string(((const struct bt_error_cause *) (_cause))->actor_type), \
43 bt_error_cause_actor_type_string(_exp_type))
46 void fini_component_class_id(
47 struct bt_error_cause_component_class_id
*comp_class_id
)
49 BT_ASSERT(comp_class_id
);
51 if (comp_class_id
->name
) {
52 g_string_free(comp_class_id
->name
, TRUE
);
53 comp_class_id
->name
= NULL
;
56 if (comp_class_id
->plugin_name
) {
57 g_string_free(comp_class_id
->plugin_name
, TRUE
);
58 comp_class_id
->plugin_name
= NULL
;
63 void fini_error_cause(struct bt_error_cause
*cause
)
66 BT_LIB_LOGD("Finalizing error cause: %!+r", cause
);
68 if (cause
->module_name
) {
69 g_string_free(cause
->module_name
, TRUE
);
70 cause
->module_name
= NULL
;
73 if (cause
->file_name
) {
74 g_string_free(cause
->file_name
, TRUE
);
75 cause
->file_name
= NULL
;
79 g_string_free(cause
->message
, TRUE
);
80 cause
->message
= NULL
;
85 void destroy_error_cause(struct bt_error_cause
*cause
)
91 BT_LIB_LOGD("Destroying error cause: %!+r", cause
);
93 switch (cause
->actor_type
) {
94 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT
:
96 struct bt_error_cause_component_actor
*spec_cause
=
99 if (spec_cause
->comp_name
) {
100 g_string_free(spec_cause
->comp_name
, TRUE
);
101 spec_cause
->comp_name
= NULL
;
104 fini_component_class_id(&spec_cause
->comp_class_id
);
107 case BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS
:
109 struct bt_error_cause_component_class_actor
*spec_cause
=
112 fini_component_class_id(&spec_cause
->comp_class_id
);
115 case BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
:
117 struct bt_error_cause_message_iterator_actor
*spec_cause
=
120 if (spec_cause
->comp_name
) {
121 g_string_free(spec_cause
->comp_name
, TRUE
);
122 spec_cause
->comp_name
= NULL
;
125 if (spec_cause
->output_port_name
) {
126 g_string_free(spec_cause
->output_port_name
, TRUE
);
127 spec_cause
->output_port_name
= NULL
;
130 fini_component_class_id(&spec_cause
->comp_class_id
);
137 fini_error_cause(cause
);
145 int init_error_cause(struct bt_error_cause
*cause
,
146 enum bt_error_cause_actor_type actor_type
)
151 BT_LIB_LOGD("Initializing error cause: %!+r", cause
);
152 cause
->actor_type
= actor_type
;
153 cause
->module_name
= g_string_new(NULL
);
154 if (!cause
->module_name
) {
155 BT_LOGE_STR("Failed to allocate one GString.");
160 cause
->message
= g_string_new(NULL
);
161 if (!cause
->message
) {
162 BT_LOGE_STR("Failed to allocate one GString.");
167 cause
->file_name
= g_string_new(NULL
);
168 if (!cause
->file_name
) {
169 BT_LOGE_STR("Failed to allocate one GString.");
174 BT_LIB_LOGD("Initialized error cause: %!+r", cause
);
181 int init_component_class_id(
182 struct bt_error_cause_component_class_id
*comp_class_id
,
183 struct bt_component_class
*comp_cls
)
187 BT_ASSERT(comp_class_id
);
188 comp_class_id
->type
= comp_cls
->type
;
189 comp_class_id
->name
= g_string_new(comp_cls
->name
->str
);
190 if (!comp_class_id
->name
) {
191 BT_LOGE_STR("Failed to allocate one GString.");
196 comp_class_id
->plugin_name
= g_string_new(comp_cls
->plugin_name
->str
);
197 if (!comp_class_id
->plugin_name
) {
198 BT_LOGE_STR("Failed to allocate one GString.");
208 void set_error_cause_props(struct bt_error_cause
*cause
,
209 const char *file_name
, uint64_t line_no
)
212 g_string_assign(cause
->file_name
, file_name
);
213 cause
->line_no
= line_no
;
217 struct bt_error_cause
*create_error_cause(const char *module_name
,
218 const char *file_name
, uint64_t line_no
)
220 struct bt_error_cause
*cause
= g_new0(struct bt_error_cause
, 1);
223 BT_LOGD_STR("Creating error cause (unknown actor).");
226 BT_LOGE_STR("Failed to allocate one error cause.");
230 ret
= init_error_cause(cause
, BT_ERROR_CAUSE_ACTOR_TYPE_UNKNOWN
);
235 g_string_assign(cause
->module_name
, module_name
);
236 set_error_cause_props(cause
, file_name
, line_no
);
237 BT_LIB_LOGD("Created error cause: %!+r", cause
);
241 destroy_error_cause(cause
);
249 void append_component_class_id_str(GString
*str
,
250 struct bt_error_cause_component_class_id
*comp_class_id
)
252 const char *type_str
= NULL
;
254 switch (comp_class_id
->type
) {
255 case BT_COMPONENT_CLASS_TYPE_SOURCE
:
258 case BT_COMPONENT_CLASS_TYPE_FILTER
:
261 case BT_COMPONENT_CLASS_TYPE_SINK
:
268 if (comp_class_id
->plugin_name
->len
> 0) {
269 g_string_append_printf(str
, "%s.%s.%s",
270 type_str
, comp_class_id
->plugin_name
->str
,
271 comp_class_id
->name
->str
);
273 g_string_append_printf(str
, "%s.%s",
274 type_str
, comp_class_id
->name
->str
);
279 struct bt_error_cause_component_actor
*create_error_cause_component_actor(
280 struct bt_component
*comp
, const char *file_name
,
283 struct bt_error_cause_component_actor
*cause
=
284 g_new0(struct bt_error_cause_component_actor
, 1);
287 BT_LOGD_STR("Creating error cause object (component actor).");
293 ret
= init_error_cause(&cause
->base
,
294 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT
);
299 set_error_cause_props(&cause
->base
, file_name
, line_no
);
300 cause
->comp_name
= g_string_new(comp
->name
->str
);
301 if (!cause
->comp_name
) {
302 BT_LOGE_STR("Failed to allocate one GString.");
306 ret
= init_component_class_id(&cause
->comp_class_id
, comp
->class);
311 g_string_append_printf(cause
->base
.module_name
, "%s: ",
313 append_component_class_id_str(cause
->base
.module_name
,
314 &cause
->comp_class_id
);
315 BT_LIB_LOGD("Created error cause object: %!+r", cause
);
319 destroy_error_cause(&cause
->base
);
327 struct bt_error_cause_component_class_actor
*
328 create_error_cause_component_class_actor(struct bt_component_class
*comp_cls
,
329 const char *file_name
, uint64_t line_no
)
331 struct bt_error_cause_component_class_actor
*cause
=
332 g_new0(struct bt_error_cause_component_class_actor
, 1);
335 BT_LOGD_STR("Creating error cause object (component class actor).");
338 BT_LOGE_STR("Failed to allocate one error cause object.");
342 ret
= init_error_cause(&cause
->base
,
343 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS
);
348 set_error_cause_props(&cause
->base
, file_name
, line_no
);
349 ret
= init_component_class_id(&cause
->comp_class_id
, comp_cls
);
354 append_component_class_id_str(cause
->base
.module_name
,
355 &cause
->comp_class_id
);
356 BT_LIB_LOGD("Created error cause object: %!+r", cause
);
360 destroy_error_cause(&cause
->base
);
367 struct bt_error_cause_message_iterator_actor
*
368 create_error_cause_message_iterator_actor(struct bt_message_iterator
*iter
,
369 const char *file_name
, uint64_t line_no
)
371 struct bt_error_cause_message_iterator_actor
*cause
;
372 struct bt_self_component_port_input_message_iterator
*input_port_iter
;
375 BT_LOGD_STR("Creating error cause object (message iterator actor).");
378 * This can only be created from within a graph, from a user
379 * message iterator, which is a self component port input
382 BT_ASSERT(iter
->type
==
383 BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT
);
384 input_port_iter
= (void *) iter
;
385 cause
= g_new0(struct bt_error_cause_message_iterator_actor
, 1);
387 BT_LOGE_STR("Failed to allocate one error cause object.");
391 ret
= init_error_cause(&cause
->base
,
392 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
);
397 set_error_cause_props(&cause
->base
, file_name
, line_no
);
398 cause
->comp_name
= g_string_new(
399 input_port_iter
->upstream_component
->name
->str
);
400 if (!cause
->comp_name
) {
401 BT_LOGE_STR("Failed to allocate one GString.");
405 cause
->output_port_name
= g_string_new(
406 input_port_iter
->upstream_port
->name
->str
);
407 if (!cause
->output_port_name
) {
408 BT_LOGE_STR("Failed to allocate one GString.");
412 ret
= init_component_class_id(&cause
->comp_class_id
,
413 input_port_iter
->upstream_component
->class);
418 g_string_append_printf(cause
->base
.module_name
, "%s (%s): ",
419 input_port_iter
->upstream_component
->name
->str
,
420 input_port_iter
->upstream_port
->name
->str
);
421 append_component_class_id_str(cause
->base
.module_name
,
422 &cause
->comp_class_id
);
423 BT_LIB_LOGD("Created error cause object: %!+r", cause
);
427 destroy_error_cause(&cause
->base
);
435 struct bt_error
*bt_error_create(void)
437 struct bt_error
*error
;
439 BT_LOGD_STR("Creating error object.");
440 error
= g_new0(struct bt_error
, 1);
442 BT_LOGE_STR("Failed to allocate one error object.");
446 error
->causes
= g_ptr_array_new_with_free_func(
447 (GDestroyNotify
) destroy_error_cause
);
448 if (!error
->causes
) {
449 BT_LOGE_STR("Failed to allocate one GPtrArray.");
453 BT_LOGD("Created error object: addr=%p", error
);
457 bt_error_destroy(error
);
465 void bt_error_destroy(struct bt_error
*error
)
472 g_ptr_array_free(error
->causes
, TRUE
);
473 error
->causes
= NULL
;
483 int bt_error_append_cause_from_unknown(struct bt_error
*error
,
484 const char *module_name
, const char *file_name
,
485 uint64_t line_no
, const char *msg_fmt
, va_list args
)
487 struct bt_error_cause
*cause
= NULL
;
488 int status
= BT_FUNC_STATUS_OK
;
490 BT_ASSERT_PRE_NON_NULL(error
, "Error");
491 BT_ASSERT_PRE_NON_NULL(module_name
, "Module name");
492 BT_ASSERT_PRE_NON_NULL(file_name
, "Function name");
493 BT_ASSERT_PRE_NON_NULL(msg_fmt
, "Message format string");
494 BT_LOGD("Appending error cause from unknown actor: "
495 "module-name=\"%s\", func-name=\"%s\", line-no=%" PRIu64
,
496 module_name
, file_name
, line_no
);
497 cause
= create_error_cause(module_name
, file_name
, line_no
);
499 /* create_error_cause() logs errors */
500 status
= BT_FUNC_STATUS_MEMORY_ERROR
;
504 g_string_append_vprintf(cause
->message
, msg_fmt
, args
);
505 g_ptr_array_add(error
->causes
, cause
);
506 BT_LIB_LOGD("Appended error cause: %!+r", cause
);
510 destroy_error_cause(cause
);
515 int bt_error_append_cause_from_component(
516 struct bt_error
*error
, bt_self_component
*self_comp
,
517 const char *file_name
, uint64_t line_no
,
518 const char *msg_fmt
, va_list args
)
520 struct bt_error_cause_component_actor
*cause
= NULL
;
521 int status
= BT_FUNC_STATUS_OK
;
523 BT_ASSERT_PRE_NON_NULL(error
, "Error");
524 BT_ASSERT_PRE_NON_NULL(self_comp
, "Component");
525 BT_ASSERT_PRE_NON_NULL(file_name
, "Function name");
526 BT_ASSERT_PRE_NON_NULL(msg_fmt
, "Message format string");
527 BT_LIB_LOGD("Appending error cause from component actor: %![comp-]+c",
529 cause
= create_error_cause_component_actor((void *) self_comp
,
532 /* create_error_cause_component_actor() logs errors */
533 status
= BT_FUNC_STATUS_MEMORY_ERROR
;
537 g_string_append_vprintf(cause
->base
.message
, msg_fmt
, args
);
538 g_ptr_array_add(error
->causes
, cause
);
539 BT_LIB_LOGD("Appended error cause: %!+r", cause
);
543 destroy_error_cause(&cause
->base
);
548 int bt_error_append_cause_from_component_class(
549 struct bt_error
*error
,
550 bt_self_component_class
*self_comp_class
,
551 const char *file_name
, uint64_t line_no
,
552 const char *msg_fmt
, va_list args
)
554 struct bt_error_cause_component_class_actor
*cause
= NULL
;
555 int status
= BT_FUNC_STATUS_OK
;
557 BT_ASSERT_PRE_NON_NULL(error
, "Error");
558 BT_ASSERT_PRE_NON_NULL(self_comp_class
, "Component class");
559 BT_ASSERT_PRE_NON_NULL(file_name
, "Function name");
560 BT_ASSERT_PRE_NON_NULL(msg_fmt
, "Message format string");
561 BT_LIB_LOGD("Appending error cause from component class actor: "
562 "%![comp-cls-]+C", self_comp_class
);
563 cause
= create_error_cause_component_class_actor(
564 (void *) self_comp_class
, file_name
, line_no
);
566 /* create_error_cause_component_class_actor() logs errors */
567 status
= BT_FUNC_STATUS_MEMORY_ERROR
;
571 g_string_append_vprintf(cause
->base
.message
, msg_fmt
, args
);
572 g_ptr_array_add(error
->causes
, cause
);
573 BT_LIB_LOGD("Appended error cause: %!+r", cause
);
577 destroy_error_cause(&cause
->base
);
582 int bt_error_append_cause_from_message_iterator(
583 struct bt_error
*error
, bt_self_message_iterator
*self_iter
,
584 const char *file_name
, uint64_t line_no
,
585 const char *msg_fmt
, va_list args
)
587 struct bt_error_cause_message_iterator_actor
*cause
= NULL
;
588 int status
= BT_FUNC_STATUS_OK
;
590 BT_ASSERT_PRE_NON_NULL(error
, "Error");
591 BT_ASSERT_PRE_NON_NULL(self_iter
, "Message iterator");
592 BT_ASSERT_PRE_NON_NULL(file_name
, "Function name");
593 BT_ASSERT_PRE_NON_NULL(msg_fmt
, "Message format string");
594 BT_LIB_LOGD("Appending error cause from message iterator actor: "
595 "%![comp-]+i", self_iter
);
596 cause
= create_error_cause_message_iterator_actor(
597 (void *) self_iter
, file_name
, line_no
);
599 /* create_error_cause_message_iterator_actor() logs errors */
600 status
= BT_FUNC_STATUS_MEMORY_ERROR
;
604 g_string_append_vprintf(cause
->base
.message
, msg_fmt
, args
);
605 g_ptr_array_add(error
->causes
, cause
);
606 BT_LIB_LOGD("Appended error cause: %!+r", cause
);
610 destroy_error_cause(&cause
->base
);
615 uint64_t error_cause_count(const bt_error
*error
)
617 return error
->causes
? error
->causes
->len
: 0;
620 uint64_t bt_error_get_cause_count(const bt_error
*error
)
622 BT_ASSERT_PRE_NON_NULL(error
, "Error");
623 return error_cause_count(error
);
626 void bt_error_release(const struct bt_error
*error
)
628 BT_ASSERT_PRE_NON_NULL(error
, "Error");
629 bt_error_destroy((void *) error
);
632 const struct bt_error_cause
*bt_error_borrow_cause_by_index(
633 const bt_error
*error
, uint64_t index
)
635 BT_ASSERT_PRE_NON_NULL(error
, "Error");
636 BT_ASSERT_PRE_VALID_INDEX(index
, error_cause_count(error
));
637 return error
->causes
->pdata
[index
];
640 enum bt_error_cause_actor_type
bt_error_cause_get_actor_type(
641 const struct bt_error_cause
*cause
)
643 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
644 return cause
->actor_type
;
647 const char *bt_error_cause_get_message(const struct bt_error_cause
*cause
)
649 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
650 return cause
->message
->str
;
653 const char *bt_error_cause_get_module_name(const struct bt_error_cause
*cause
)
655 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
656 return cause
->module_name
->str
;
659 const char *bt_error_cause_get_file_name(const struct bt_error_cause
*cause
)
661 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
662 return cause
->file_name
->str
;
665 uint64_t bt_error_cause_get_line_number(const bt_error_cause
*cause
)
667 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
668 return cause
->line_no
;
671 const char *bt_error_cause_component_actor_get_component_name(
672 const struct bt_error_cause
*cause
)
674 const struct bt_error_cause_component_actor
*spec_cause
=
675 (const void *) cause
;
677 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
678 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
679 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT
);
680 return spec_cause
->comp_name
->str
;
683 bt_component_class_type
bt_error_cause_component_actor_get_component_class_type(
684 const struct bt_error_cause
*cause
)
686 const struct bt_error_cause_component_actor
*spec_cause
=
687 (const void *) cause
;
689 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
690 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
691 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT
);
692 return spec_cause
->comp_class_id
.type
;
695 const char *bt_error_cause_component_actor_get_component_class_name(
696 const struct bt_error_cause
*cause
)
698 const struct bt_error_cause_component_actor
*spec_cause
=
699 (const void *) cause
;
701 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
702 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
703 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT
);
704 return spec_cause
->comp_class_id
.name
->str
;
707 const char *bt_error_cause_component_actor_get_plugin_name(
708 const struct bt_error_cause
*cause
)
710 const struct bt_error_cause_component_actor
*spec_cause
=
711 (const void *) cause
;
713 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
714 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
715 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT
);
716 return spec_cause
->comp_class_id
.plugin_name
->len
> 0 ?
717 spec_cause
->comp_class_id
.plugin_name
->str
: NULL
;
720 bt_component_class_type
721 bt_error_cause_component_class_actor_get_component_class_type(
722 const struct bt_error_cause
*cause
)
724 const struct bt_error_cause_component_class_actor
*spec_cause
=
725 (const void *) cause
;
727 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
728 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
729 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS
);
730 return spec_cause
->comp_class_id
.type
;
733 const char *bt_error_cause_component_class_actor_get_component_class_name(
734 const struct bt_error_cause
*cause
)
736 const struct bt_error_cause_component_class_actor
*spec_cause
=
737 (const void *) cause
;
739 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
740 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
741 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS
);
742 return spec_cause
->comp_class_id
.name
->str
;
745 const char *bt_error_cause_component_class_actor_get_plugin_name(
746 const struct bt_error_cause
*cause
)
748 const struct bt_error_cause_component_class_actor
*spec_cause
=
749 (const void *) cause
;
751 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
752 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
753 BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS
);
754 return spec_cause
->comp_class_id
.plugin_name
->len
> 0 ?
755 spec_cause
->comp_class_id
.plugin_name
->str
: NULL
;
758 const char *bt_error_cause_message_iterator_actor_get_component_name(
759 const struct bt_error_cause
*cause
)
761 const struct bt_error_cause_message_iterator_actor
*spec_cause
=
762 (const void *) cause
;
764 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
765 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
766 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
);
767 return spec_cause
->comp_name
->str
;
771 bt_error_cause_message_iterator_actor_get_component_output_port_name(
772 const struct bt_error_cause
*cause
)
774 const struct bt_error_cause_message_iterator_actor
*spec_cause
=
775 (const void *) cause
;
777 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
778 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
779 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
);
780 return spec_cause
->output_port_name
->str
;
783 bt_component_class_type
784 bt_error_cause_message_iterator_actor_get_component_class_type(
785 const struct bt_error_cause
*cause
)
787 const struct bt_error_cause_message_iterator_actor
*spec_cause
=
788 (const void *) cause
;
790 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
791 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
792 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
);
793 return spec_cause
->comp_class_id
.type
;
796 const char *bt_error_cause_message_iterator_actor_get_component_class_name(
797 const struct bt_error_cause
*cause
)
799 const struct bt_error_cause_message_iterator_actor
*spec_cause
=
800 (const void *) cause
;
802 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
803 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
804 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
);
805 return spec_cause
->comp_class_id
.name
->str
;
808 const char *bt_error_cause_message_iterator_actor_get_plugin_name(
809 const struct bt_error_cause
*cause
)
811 const struct bt_error_cause_message_iterator_actor
*spec_cause
=
812 (const void *) cause
;
814 BT_ASSERT_PRE_NON_NULL(cause
, "Error cause");
815 BT_ASSERT_PRE_CAUSE_HAS_ACTOR_TYPE(cause
,
816 BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR
);
817 return spec_cause
->comp_class_id
.plugin_name
->len
> 0 ?
818 spec_cause
->comp_class_id
.plugin_name
->str
: NULL
;