| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation |
| 5 | */ |
| 6 | |
| 7 | /* IWYU pragma: private, include <babeltrace2/babeltrace.h> */ |
| 8 | |
| 9 | #ifndef BABELTRACE2_ERROR_REPORTING_H |
| 10 | #define BABELTRACE2_ERROR_REPORTING_H |
| 11 | |
| 12 | #ifndef __BT_IN_BABELTRACE_H |
| 13 | # error "Please include <babeltrace2/babeltrace.h> instead." |
| 14 | #endif |
| 15 | |
| 16 | #include <stdarg.h> |
| 17 | |
| 18 | #include <babeltrace2/types.h> |
| 19 | #include <babeltrace2/graph/component-class.h> |
| 20 | |
| 21 | #ifdef __cplusplus |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | /*! |
| 26 | @defgroup api-error Error reporting |
| 27 | |
| 28 | @brief |
| 29 | Error reporting functions and macros. |
| 30 | |
| 31 | This API offers functions and macros to report rich |
| 32 | errors from a user function (a \bt_comp_cls method, a |
| 33 | \ref api-qexec "query operation", or a trace processing \bt_graph |
| 34 | listener, for example) to any function caller. |
| 35 | |
| 36 | Because \bt_name orchestrates pieces written by different authors, |
| 37 | it is important that an error which occurs deep into the function call |
| 38 | stack can percolate up to its callers. |
| 39 | |
| 40 | The very basic mechanism to report an error from a function is to |
| 41 | \ref api-fund-func-status "return an error status" |
| 42 | (a status code enumerator which contains the word |
| 43 | \c ERROR): each function caller can clean its own context and return an |
| 44 | error status code itself until one caller "catches" the status code and |
| 45 | reacts to it. For example, the reaction can be to show an error message |
| 46 | to the end user. |
| 47 | |
| 48 | This error reporting API adds a layer so that each function which |
| 49 | returns an error status code can append a message which describes the |
| 50 | cause of the error within the function's context. |
| 51 | |
| 52 | Functions append error causes to the current thread's error. Having one |
| 53 | error object per thread makes this API thread-safe. |
| 54 | |
| 55 | Here's a visual, step-by-step example: |
| 56 | |
| 57 | @image html error-reporting-steps-1234.png |
| 58 | |
| 59 | -# The trace processing \bt_graph user calls bt_graph_run(). |
| 60 | |
| 61 | -# bt_graph_run() calls the |
| 62 | \ref api-comp-cls-dev-meth-consume "consuming method" of the |
| 63 | \bt_sink_comp. |
| 64 | |
| 65 | -# The sink \bt_comp calls bt_message_iterator_next() on its upstream |
| 66 | source \bt_msg_iter. |
| 67 | |
| 68 | -# bt_message_iterator_next() calls the source message iterator's |
| 69 | \link api-msg-iter-cls-meth-next "next" method\endlink. |
| 70 | |
| 71 | @image html error-reporting-step-5.png |
| 72 | |
| 73 | <ol start="5"> |
| 74 | <li> |
| 75 | An error occurs within the "next" method of the source message |
| 76 | iterator: the function cannot read a file because permission was |
| 77 | denied. |
| 78 | </ol> |
| 79 | |
| 80 | @image html error-reporting-step-6.png |
| 81 | |
| 82 | <ol start="6"> |
| 83 | <li> |
| 84 | The source message iterator's "next" method appends the error |
| 85 | cause <em>"Cannot read file /some/file: permission denied"</em> |
| 86 | and returns |
| 87 | #BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR. |
| 88 | </ol> |
| 89 | |
| 90 | @image html error-reporting-step-7.png |
| 91 | |
| 92 | <ol start="7"> |
| 93 | <li> |
| 94 | bt_message_iterator_next() appends |
| 95 | the error cause <em>"Message iterator's 'next' method failed"</em> |
| 96 | with details about the source component and |
| 97 | returns #BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR. |
| 98 | </ol> |
| 99 | |
| 100 | @image html error-reporting-steps-89.png |
| 101 | |
| 102 | <ol start="8"> |
| 103 | <li> |
| 104 | The sink component's "consume" method appends the error |
| 105 | cause <em>"Cannot consume upstream message iterator's messages"</em> |
| 106 | and returns #BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR. |
| 107 | |
| 108 | <li> |
| 109 | bt_graph_run() appends the error cause <em>"Component's 'consume' |
| 110 | method failed"</em> with details about the sink component and |
| 111 | returns #BT_GRAPH_RUN_STATUS_ERROR. |
| 112 | </ol> |
| 113 | |
| 114 | At this point, the current thread's error contains four causes: |
| 115 | |
| 116 | - <em>"Cannot read file /some/file: permission denied"</em> |
| 117 | - <em>"Message iterator's 'next' method failed"</em> |
| 118 | - <em>"Cannot consume upstream message iterator's messages"</em> |
| 119 | - <em>"Component's 'consume' method failed"</em> |
| 120 | |
| 121 | This list of error causes is much richer for the end user than dealing |
| 122 | only with #BT_GRAPH_RUN_STATUS_ERROR (the last error status code). |
| 123 | |
| 124 | Both error (#bt_error) and error cause (#bt_error_cause) objects are |
| 125 | \ref api-fund-unique-object "unique objects": |
| 126 | |
| 127 | - An error belongs to either |
| 128 | the library or you (see \ref api-error-handle "Handle an error"). |
| 129 | |
| 130 | - An error cause belongs to the error which contains it. |
| 131 | |
| 132 | <h1>\anchor api-error-append-cause Append an error cause</h1> |
| 133 | |
| 134 | When your function returns an error status code, use one of the |
| 135 | <code>bt_current_thread_error_append_cause_from_*()</code> |
| 136 | functions or <code>BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_*()</code> |
| 137 | macros to append an error cause to the |
| 138 | current thread's error. Use the appropriate function or macro |
| 139 | depending on your function's actor amongst: |
| 140 | |
| 141 | <dl> |
| 142 | <dt>Component</dt> |
| 143 | <dd> |
| 144 | Append an error cause from a \bt_comp method. |
| 145 | |
| 146 | Use bt_current_thread_error_append_cause_from_component() or |
| 147 | BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT(). |
| 148 | </dd> |
| 149 | |
| 150 | <dt>Message iterator</dt> |
| 151 | <dd> |
| 152 | Append an error cause from a \bt_msg_iter method. |
| 153 | |
| 154 | Use bt_current_thread_error_append_cause_from_message_iterator() or |
| 155 | BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_MESSAGE_ITERATOR(). |
| 156 | </dd> |
| 157 | |
| 158 | <dt>Component class</dt> |
| 159 | <dd> |
| 160 | Append an error cause from a \bt_comp_cls method |
| 161 | ("query" method). |
| 162 | |
| 163 | Use bt_current_thread_error_append_cause_from_component_class() or |
| 164 | BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT_CLASS(). |
| 165 | </dd> |
| 166 | |
| 167 | <dt>Unknown</dt> |
| 168 | <dd> |
| 169 | Append an error cause from any other function, for example |
| 170 | a \bt_graph listener or a function of your user application). |
| 171 | |
| 172 | Use bt_current_thread_error_append_cause_from_unknown() or |
| 173 | BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(). |
| 174 | </dd> |
| 175 | </dl> |
| 176 | |
| 177 | The <code>BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_*()</code> macros |
| 178 | uses \c __FILE__ and \c __LINE__ as the file name and line number |
| 179 | parameters of their corresponding |
| 180 | <code>bt_current_thread_error_append_cause_from_*()</code> function. |
| 181 | |
| 182 | <h1>\anchor api-error-handle Handle an error</h1> |
| 183 | |
| 184 | If any libbabeltrace2 function you call returns an error status code, do |
| 185 | one of: |
| 186 | |
| 187 | - Return an error status code too. |
| 188 | |
| 189 | In that case, you \em can |
| 190 | \ref api-error-append-cause "append an error cause" to the current |
| 191 | thread's error. |
| 192 | |
| 193 | - \em Take the current thread's error with |
| 194 | bt_current_thread_take_error(). |
| 195 | |
| 196 | This function moves the ownership of the error object from the library |
| 197 | to you. |
| 198 | |
| 199 | At this point, you can inspect its causes with |
| 200 | bt_error_get_cause_count() and bt_error_borrow_cause_by_index(), and |
| 201 | then do one of: |
| 202 | |
| 203 | - Call bt_error_release() to free the error object. |
| 204 | |
| 205 | In <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented programming</a> |
| 206 | terms, this corresponds to catching an exception and discarding it. |
| 207 | |
| 208 | - Call bt_current_thread_move_error() to move back the error object's |
| 209 | ownership to the library. |
| 210 | |
| 211 | In object-oriented programming terms, this corresponds to catching |
| 212 | an exception and rethrowing it. |
| 213 | |
| 214 | bt_current_thread_clear_error() is a helper which is the equivalent of: |
| 215 | |
| 216 | @code |
| 217 | bt_error_release(bt_current_thread_take_error()); |
| 218 | @endcode |
| 219 | |
| 220 | <h1>Error cause</h1> |
| 221 | |
| 222 | All error causes have the type #bt_error_cause. |
| 223 | |
| 224 | There are four types of error cause actors: |
| 225 | |
| 226 | - \bt_c_comp |
| 227 | - \bt_c_msg_iter |
| 228 | - \bt_c_comp_cls |
| 229 | - Unknown |
| 230 | |
| 231 | Get the type enumerator of an error cause's actor with |
| 232 | bt_error_cause_get_actor_type(). |
| 233 | |
| 234 | An error cause has the following common properties: |
| 235 | |
| 236 | <dl> |
| 237 | <dt>Message</dt> |
| 238 | <dd> |
| 239 | Description of the error cause. |
| 240 | |
| 241 | Use bt_error_cause_get_message(). |
| 242 | </dd> |
| 243 | |
| 244 | <dt>Module name</dt> |
| 245 | <dd> |
| 246 | Name of the module causing the error. |
| 247 | |
| 248 | For example, libbabeltrace2 uses "libbabeltrace2" and the \bt_cli |
| 249 | CLI tool uses "Babeltrace CLI". |
| 250 | |
| 251 | Use bt_error_cause_get_module_name(). |
| 252 | </dd> |
| 253 | |
| 254 | <dt>File name</dt> |
| 255 | <dd> |
| 256 | Name of the source file causing the error. |
| 257 | |
| 258 | Use bt_error_cause_get_file_name(). |
| 259 | </dd> |
| 260 | |
| 261 | <dt>Line number</dt> |
| 262 | <dd> |
| 263 | Line number of the statement causing the error. |
| 264 | |
| 265 | Use bt_error_cause_get_line_number(). |
| 266 | </dd> |
| 267 | </dl> |
| 268 | |
| 269 | <h2>Error cause with a component actor</h2> |
| 270 | |
| 271 | An error cause with a \bt_comp actor has the following specific |
| 272 | properties: |
| 273 | |
| 274 | <dl> |
| 275 | <dt>Component name</dt> |
| 276 | <dd> |
| 277 | Name of the component. |
| 278 | |
| 279 | Use bt_error_cause_component_actor_get_component_name(). |
| 280 | </dd> |
| 281 | |
| 282 | <dt>Component class name</dt> |
| 283 | <dd> |
| 284 | Name of the component's \ref api-comp-cls "class". |
| 285 | |
| 286 | Use bt_error_cause_component_actor_get_component_class_type(). |
| 287 | </dd> |
| 288 | |
| 289 | <dt>Component class type</dt> |
| 290 | <dd> |
| 291 | Type of the component's class. |
| 292 | |
| 293 | Use bt_error_cause_component_actor_get_component_class_name(). |
| 294 | </dd> |
| 295 | |
| 296 | <dt>\bt_dt_opt Plugin name</dt> |
| 297 | <dd> |
| 298 | Name of the \bt_plugin which provides the component's class, if any. |
| 299 | |
| 300 | Use bt_error_cause_component_actor_get_plugin_name(). |
| 301 | </dd> |
| 302 | </dl> |
| 303 | |
| 304 | <h2>Error cause with a message iterator actor</h2> |
| 305 | |
| 306 | An error cause with a \bt_msg_iter actor has the following specific |
| 307 | properties: |
| 308 | |
| 309 | <dl> |
| 310 | <dt>Component output port name</dt> |
| 311 | <dd> |
| 312 | Name of the \bt_comp \bt_oport from which the message iterator |
| 313 | was created. |
| 314 | |
| 315 | Use bt_error_cause_component_actor_get_component_name(). |
| 316 | </dd> |
| 317 | |
| 318 | <dt>Component name</dt> |
| 319 | <dd> |
| 320 | Name of the component. |
| 321 | |
| 322 | Use bt_error_cause_component_actor_get_component_name(). |
| 323 | </dd> |
| 324 | |
| 325 | bt_error_cause_message_iterator_actor_get_component_output_port_name |
| 326 | |
| 327 | <dt>Component class name</dt> |
| 328 | <dd> |
| 329 | Name of the component's \ref api-comp-cls "class". |
| 330 | |
| 331 | Use bt_error_cause_component_actor_get_component_class_type(). |
| 332 | </dd> |
| 333 | |
| 334 | <dt>Component class type</dt> |
| 335 | <dd> |
| 336 | Type of the component's class. |
| 337 | |
| 338 | Use bt_error_cause_component_actor_get_component_class_name(). |
| 339 | </dd> |
| 340 | |
| 341 | <dt>\bt_dt_opt Plugin name</dt> |
| 342 | <dd> |
| 343 | Name of the \bt_plugin which provides the component's class, if any. |
| 344 | |
| 345 | Use bt_error_cause_component_actor_get_plugin_name(). |
| 346 | </dd> |
| 347 | </dl> |
| 348 | |
| 349 | <h2>Error cause with a component class actor</h2> |
| 350 | |
| 351 | An error cause with a \bt_comp_cls actor has the following specific |
| 352 | properties: |
| 353 | |
| 354 | <dl> |
| 355 | <dt>Component class name</dt> |
| 356 | <dd> |
| 357 | Name of the component class. |
| 358 | |
| 359 | Use bt_error_cause_component_class_actor_get_component_class_type(). |
| 360 | </dd> |
| 361 | |
| 362 | <dt>Component class type</dt> |
| 363 | <dd> |
| 364 | Type of the component class. |
| 365 | |
| 366 | Use bt_error_cause_component_class_actor_get_component_class_name(). |
| 367 | </dd> |
| 368 | |
| 369 | <dt>\bt_dt_opt Plugin name</dt> |
| 370 | <dd> |
| 371 | Name of the \bt_plugin which provides the component class, if any. |
| 372 | |
| 373 | Use bt_error_cause_component_class_actor_get_plugin_name(). |
| 374 | </dd> |
| 375 | </dl> |
| 376 | */ |
| 377 | |
| 378 | /*! @{ */ |
| 379 | |
| 380 | /*! |
| 381 | @name Types |
| 382 | @{ |
| 383 | |
| 384 | @typedef struct bt_error bt_error; |
| 385 | |
| 386 | @brief |
| 387 | Error. |
| 388 | |
| 389 | @typedef struct bt_error_cause bt_error_cause; |
| 390 | |
| 391 | @brief |
| 392 | Error cause. |
| 393 | |
| 394 | @} |
| 395 | */ |
| 396 | |
| 397 | /*! |
| 398 | @name Current thread's error |
| 399 | @{ |
| 400 | */ |
| 401 | |
| 402 | /*! |
| 403 | @brief |
| 404 | \em Takes the current thread's error, that is, moves its ownership |
| 405 | from the library to the caller. |
| 406 | |
| 407 | This function can return \c NULL if the current thread has no error. |
| 408 | |
| 409 | Once you are done with the returned error, do one of: |
| 410 | |
| 411 | - Call bt_error_release() to free the error object. |
| 412 | |
| 413 | In <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented programming</a> |
| 414 | terms, this corresponds to catching an exception and discarding it. |
| 415 | |
| 416 | - Call bt_current_thread_move_error() to move back the error object's |
| 417 | ownership to the library. |
| 418 | |
| 419 | In object-oriented programming terms, this corresponds to catching |
| 420 | an exception and rethrowing it. |
| 421 | |
| 422 | @returns |
| 423 | Unique reference of the current thread's error, or \c NULL if the |
| 424 | current thread has no error. |
| 425 | |
| 426 | @post |
| 427 | <strong>If this function does not return <code>NULL</code></strong>, |
| 428 | the caller owns the returned error. |
| 429 | |
| 430 | @sa bt_error_release() — |
| 431 | Releases (frees) an error. |
| 432 | @sa bt_current_thread_move_error() — |
| 433 | Moves an error's ownership to the library. |
| 434 | */ |
| 435 | extern |
| 436 | const bt_error *bt_current_thread_take_error(void) __BT_NOEXCEPT; |
| 437 | |
| 438 | /*! |
| 439 | @brief |
| 440 | Moves the ownership of the error \bt_p{error} from the caller to |
| 441 | the library. |
| 442 | |
| 443 | After you call this function, you don't own \bt_p{error} anymore. |
| 444 | |
| 445 | In <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented programming</a> |
| 446 | terms, calling this function corresponds to catching an |
| 447 | exception and rethrowing it. |
| 448 | |
| 449 | You can instead release (free) the error with bt_error_release(), which, |
| 450 | in object-oriented programming terms, |
| 451 | corresponds to catching an exception and discarding it. |
| 452 | |
| 453 | @param[in] error |
| 454 | Error of which to move the ownership from you to the library. |
| 455 | |
| 456 | @bt_pre_not_null{error} |
| 457 | @pre |
| 458 | The caller owns \bt_p{error}. |
| 459 | |
| 460 | @post |
| 461 | The library owns \bt_p{error}. |
| 462 | |
| 463 | @sa bt_error_release() — |
| 464 | Releases (frees) an error. |
| 465 | @sa BT_CURRENT_THREAD_MOVE_ERROR_AND_RESET() — |
| 466 | Calls this function and assigns \c NULL to the expression. |
| 467 | */ |
| 468 | extern |
| 469 | void bt_current_thread_move_error(const bt_error *error) __BT_NOEXCEPT; |
| 470 | |
| 471 | /*! |
| 472 | @brief |
| 473 | Moves the ownership of the error \bt_p{_error} from the caller to |
| 474 | the library, and then sets \bt_p{_error} to \c NULL. |
| 475 | |
| 476 | @param[in] _error |
| 477 | Error of which to move the ownership from you to the library. |
| 478 | |
| 479 | @bt_pre_not_null{_error} |
| 480 | @bt_pre_assign_expr{_error} |
| 481 | @pre |
| 482 | The caller owns \bt_p{_error}. |
| 483 | |
| 484 | @post |
| 485 | The library owns \bt_p{_error}. |
| 486 | |
| 487 | @sa bt_current_thread_move_error() — |
| 488 | Moves an error's ownership to the library. |
| 489 | */ |
| 490 | #define BT_CURRENT_THREAD_MOVE_ERROR_AND_RESET(_error) \ |
| 491 | do { \ |
| 492 | bt_current_thread_move_error(_error); \ |
| 493 | (_error) = NULL; \ |
| 494 | } while (0) |
| 495 | |
| 496 | /*! |
| 497 | @brief |
| 498 | Releases the current thread's error, if any. |
| 499 | |
| 500 | This function is equivalent to: |
| 501 | |
| 502 | @code |
| 503 | bt_error_release(bt_current_thread_take_error()); |
| 504 | @endcode |
| 505 | |
| 506 | @post |
| 507 | The current thread has no error. |
| 508 | |
| 509 | @sa bt_error_release() — |
| 510 | Releases (frees) an error. |
| 511 | @sa bt_current_thread_take_error — |
| 512 | Takes the current thread's error, moving its ownership from the |
| 513 | library to the caller. |
| 514 | */ |
| 515 | extern |
| 516 | void bt_current_thread_clear_error(void) __BT_NOEXCEPT; |
| 517 | |
| 518 | /*! @} */ |
| 519 | |
| 520 | /*! |
| 521 | @name Error cause appending |
| 522 | @{ |
| 523 | */ |
| 524 | |
| 525 | /*! |
| 526 | @brief |
| 527 | Status codes for the |
| 528 | <code>bt_current_thread_error_append_cause_from_*()</code> |
| 529 | functions. |
| 530 | */ |
| 531 | typedef enum bt_current_thread_error_append_cause_status { |
| 532 | /*! |
| 533 | @brief |
| 534 | Success. |
| 535 | */ |
| 536 | BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_OK = __BT_FUNC_STATUS_OK, |
| 537 | |
| 538 | /*! |
| 539 | @brief |
| 540 | Out of memory. |
| 541 | */ |
| 542 | BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, |
| 543 | } bt_current_thread_error_append_cause_status; |
| 544 | |
| 545 | /*! |
| 546 | @brief |
| 547 | Appends an error cause to the current thread's error from a |
| 548 | \bt_comp method. |
| 549 | |
| 550 | This this a <code>printf()</code>-like function starting from the |
| 551 | format string parameter \bt_p{message_format}. |
| 552 | |
| 553 | On success, the appended error cause's module name |
| 554 | (see bt_error_cause_get_module_name()) is: |
| 555 | |
| 556 | @code{.unparsed} |
| 557 | NAME: CC-TYPE.PLUGIN-NAME.CC-NAME |
| 558 | @endcode |
| 559 | |
| 560 | or |
| 561 | |
| 562 | @code{.unparsed} |
| 563 | NAME: CC-TYPE.CC-NAME |
| 564 | @endcode |
| 565 | |
| 566 | if no \bt_plugin provides the class of \bt_p{self_component}, with: |
| 567 | |
| 568 | <dl> |
| 569 | <dt>\c NAME</dt> |
| 570 | <dd>Name of \bt_p{self_component}.</dd> |
| 571 | |
| 572 | <dt>\c CC-TYPE</dt> |
| 573 | <dd> |
| 574 | Type of the \ref api-comp-cls "class" of \bt_p{self_component} |
| 575 | (\c src, \c flt, or \c sink). |
| 576 | </dd> |
| 577 | |
| 578 | <dt>\c PLUGIN-NAME</dt> |
| 579 | <dd> |
| 580 | Name of the plugin which provides the class of |
| 581 | \bt_p{self_component}. |
| 582 | </dd> |
| 583 | |
| 584 | <dt>\c CC-NAME</dt> |
| 585 | <dd>Name of the class of \bt_p{self_component}.</dd> |
| 586 | </dl> |
| 587 | |
| 588 | @param[in] self_component |
| 589 | Self component of the appending method. |
| 590 | @param[in] file_name |
| 591 | Name of the source file containing the method which appends the |
| 592 | error cause. |
| 593 | @param[in] line_number |
| 594 | Line number of the statement which appends the error cause. |
| 595 | @param[in] message_format |
| 596 | Format string which specifies how the function converts the |
| 597 | subsequent arguments (like <code>printf()</code>). |
| 598 | |
| 599 | @retval #BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_OK |
| 600 | Success. |
| 601 | @retval #BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_MEMORY_ERROR |
| 602 | Out of memory. |
| 603 | |
| 604 | @bt_pre_not_null{self_component} |
| 605 | @bt_pre_not_null{file_name} |
| 606 | @bt_pre_not_null{message_format} |
| 607 | @bt_pre_valid_fmt{message_format} |
| 608 | |
| 609 | @post |
| 610 | <strong>On success</strong>, the number of error causes in the |
| 611 | current thread's error is incremented. |
| 612 | |
| 613 | @sa BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT() — |
| 614 | Calls this function with \c __FILE__ and \c __LINE__ as the |
| 615 | \bt_p{file_name} and \bt_p{line_number} parameters. |
| 616 | */ |
| 617 | extern __BT_ATTR_FORMAT_PRINTF(4, 5) |
| 618 | bt_current_thread_error_append_cause_status |
| 619 | bt_current_thread_error_append_cause_from_component( |
| 620 | bt_self_component *self_component, const char *file_name, |
| 621 | uint64_t line_number, |
| 622 | const char *message_format, ...) __BT_NOEXCEPT; |
| 623 | |
| 624 | /*! |
| 625 | @brief |
| 626 | Appends an error cause to the current thread's error from a |
| 627 | \bt_comp method using \c __FILE__ and \c __LINE__ as the source |
| 628 | file name and line number. |
| 629 | |
| 630 | This macro calls bt_current_thread_error_append_cause_from_component() |
| 631 | with \c __FILE__ and \c __LINE__ as its |
| 632 | \bt_p{file_name} and \bt_p{line_number} parameters. |
| 633 | */ |
| 634 | #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT(_self_component, _message_format, ...) \ |
| 635 | bt_current_thread_error_append_cause_from_component( \ |
| 636 | (_self_component), __FILE__, __LINE__, (_message_format), ##__VA_ARGS__) |
| 637 | |
| 638 | /*! |
| 639 | @brief |
| 640 | Appends an error cause to the current thread's error from a |
| 641 | \bt_msg_iter method. |
| 642 | |
| 643 | This this a <code>printf()</code>-like function starting from the |
| 644 | format string parameter \bt_p{message_format}. |
| 645 | |
| 646 | On success, the appended error cause's module name |
| 647 | (see bt_error_cause_get_module_name()) is: |
| 648 | |
| 649 | @code{.unparsed} |
| 650 | COMP-NAME (OUT-PORT-NAME): CC-TYPE.PLUGIN-NAME.CC-NAME |
| 651 | @endcode |
| 652 | |
| 653 | or |
| 654 | |
| 655 | @code{.unparsed} |
| 656 | COMP-NAME (OUT-PORT-NAME): CC-TYPE.CC-NAME |
| 657 | @endcode |
| 658 | |
| 659 | if no \bt_plugin provides the component class of |
| 660 | \bt_p{self_message_iterator}, with: |
| 661 | |
| 662 | <dl> |
| 663 | <dt>\c COMP-NAME</dt> |
| 664 | <dd>Name of the \bt_comp of \bt_p{self_message_iterator}.</dd> |
| 665 | |
| 666 | <dt>\c OUT-PORT-NAME</dt> |
| 667 | <dd> |
| 668 | Name of the \bt_oport from which \bt_p{self_message_iterator}. |
| 669 | was created. |
| 670 | </dd> |
| 671 | |
| 672 | <dt>\c CC-TYPE</dt> |
| 673 | <dd> |
| 674 | Type of the \bt_comp_cls of \bt_p{self_message_iterator} |
| 675 | (\c src, \c flt, or \c sink). |
| 676 | </dd> |
| 677 | |
| 678 | <dt>\c PLUGIN-NAME</dt> |
| 679 | <dd> |
| 680 | Name of the plugin which provides the component class of |
| 681 | \bt_p{self_message_iterator}. |
| 682 | </dd> |
| 683 | |
| 684 | <dt>\c CC-NAME</dt> |
| 685 | <dd>Name of the component class of \bt_p{self_message_iterator}.</dd> |
| 686 | </dl> |
| 687 | |
| 688 | @param[in] self_message_iterator |
| 689 | Self message iterator of the appending method. |
| 690 | @param[in] file_name |
| 691 | Name of the source file containing the method which appends the |
| 692 | error cause. |
| 693 | @param[in] line_number |
| 694 | Line number of the statement which appends the error cause. |
| 695 | @param[in] message_format |
| 696 | Format string which specifies how the function converts the |
| 697 | subsequent arguments (like <code>printf()</code>). |
| 698 | |
| 699 | @retval #BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_OK |
| 700 | Success. |
| 701 | @retval #BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_MEMORY_ERROR |
| 702 | Out of memory. |
| 703 | |
| 704 | @bt_pre_not_null{self_message_iterator} |
| 705 | @bt_pre_not_null{file_name} |
| 706 | @bt_pre_not_null{message_format} |
| 707 | @bt_pre_valid_fmt{message_format} |
| 708 | |
| 709 | @post |
| 710 | <strong>On success</strong>, the number of error causes in the |
| 711 | current thread's error is incremented. |
| 712 | |
| 713 | @sa BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_MESSAGE_ITERATOR() — |
| 714 | Calls this function with \c __FILE__ and \c __LINE__ as the |
| 715 | \bt_p{file_name} and \bt_p{line_number} parameters. |
| 716 | */ |
| 717 | extern __BT_ATTR_FORMAT_PRINTF(4, 5) |
| 718 | bt_current_thread_error_append_cause_status |
| 719 | bt_current_thread_error_append_cause_from_message_iterator( |
| 720 | bt_self_message_iterator *self_message_iterator, |
| 721 | const char *file_name, uint64_t line_number, |
| 722 | const char *message_format, ...) __BT_NOEXCEPT; |
| 723 | |
| 724 | /*! |
| 725 | @brief |
| 726 | Appends an error cause to the current thread's error from a |
| 727 | \bt_msg_iter method using \c __FILE__ and \c __LINE__ as the source file |
| 728 | name and line number. |
| 729 | |
| 730 | This macro calls |
| 731 | bt_current_thread_error_append_cause_from_message_iterator() with |
| 732 | \c __FILE__ and \c __LINE__ as its |
| 733 | \bt_p{file_name} and \bt_p{line_number} parameters. |
| 734 | */ |
| 735 | #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_MESSAGE_ITERATOR(_self_message_iterator, _message_format, ...) \ |
| 736 | bt_current_thread_error_append_cause_from_message_iterator( \ |
| 737 | (_self_message_iterator), __FILE__, __LINE__, (_message_format), ##__VA_ARGS__) |
| 738 | |
| 739 | /*! |
| 740 | @brief |
| 741 | Appends an error cause to the current thread's error from a |
| 742 | \bt_comp_cls method. |
| 743 | |
| 744 | This this a <code>printf()</code>-like function starting from the |
| 745 | format string parameter \bt_p{message_format}. |
| 746 | |
| 747 | As of \bt_name_version_min_maj, the only component class method is the |
| 748 | \ref api-qexec "query" method. |
| 749 | |
| 750 | On success, the appended error cause's module name |
| 751 | (see bt_error_cause_get_module_name()) is: |
| 752 | |
| 753 | @code{.unparsed} |
| 754 | CC-TYPE.PLUGIN-NAME.CC-NAME |
| 755 | @endcode |
| 756 | |
| 757 | or |
| 758 | |
| 759 | @code{.unparsed} |
| 760 | CC-TYPE.CC-NAME |
| 761 | @endcode |
| 762 | |
| 763 | if no \bt_plugin provides \bt_p{self_component_class}, with: |
| 764 | |
| 765 | <dl> |
| 766 | <dt>\c CC-TYPE</dt> |
| 767 | <dd> |
| 768 | Type of \bt_p{self_component_class} (\c src, \c flt, or \c sink). |
| 769 | </dd> |
| 770 | |
| 771 | <dt>\c PLUGIN-NAME</dt> |
| 772 | <dd> |
| 773 | Name of the plugin which provides \bt_p{self_component_class}. |
| 774 | </dd> |
| 775 | |
| 776 | <dt>\c CC-NAME</dt> |
| 777 | <dd>Name of \bt_p{self_component_class}.</dd> |
| 778 | </dl> |
| 779 | |
| 780 | @param[in] self_component_class |
| 781 | Self component class of the appending method. |
| 782 | @param[in] file_name |
| 783 | Name of the source file containing the method which appends the |
| 784 | error cause. |
| 785 | @param[in] line_number |
| 786 | Line number of the statement which appends the error cause. |
| 787 | @param[in] message_format |
| 788 | Format string which specifies how the function converts the |
| 789 | subsequent arguments (like <code>printf()</code>). |
| 790 | |
| 791 | @retval #BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_OK |
| 792 | Success. |
| 793 | @retval #BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_MEMORY_ERROR |
| 794 | Out of memory. |
| 795 | |
| 796 | @bt_pre_not_null{self_component_class} |
| 797 | @bt_pre_not_null{file_name} |
| 798 | @bt_pre_not_null{message_format} |
| 799 | @bt_pre_valid_fmt{message_format} |
| 800 | |
| 801 | @post |
| 802 | <strong>On success</strong>, the number of error causes in the |
| 803 | current thread's error is incremented. |
| 804 | |
| 805 | @sa BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT_CLASS() — |
| 806 | Calls this function with \c __FILE__ and \c __LINE__ as the |
| 807 | \bt_p{file_name} and \bt_p{line_number} parameters. |
| 808 | */ |
| 809 | extern __BT_ATTR_FORMAT_PRINTF(4, 5) |
| 810 | bt_current_thread_error_append_cause_status |
| 811 | bt_current_thread_error_append_cause_from_component_class( |
| 812 | bt_self_component_class *self_component_class, |
| 813 | const char *file_name, uint64_t line_number, |
| 814 | const char *message_format, ...) __BT_NOEXCEPT; |
| 815 | |
| 816 | /*! |
| 817 | @brief |
| 818 | Appends an error cause to the current thread's error from a |
| 819 | component class method using \c __FILE__ and \c __LINE__ as the |
| 820 | source file name and line number. |
| 821 | |
| 822 | This macro calls |
| 823 | bt_current_thread_error_append_cause_from_component_class() |
| 824 | with \c __FILE__ and \c __LINE__ as its |
| 825 | \bt_p{file_name} and \bt_p{line_number} parameters. |
| 826 | */ |
| 827 | #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT_CLASS(_self_component_class, _message_format, ...) \ |
| 828 | bt_current_thread_error_append_cause_from_component_class( \ |
| 829 | (_self_component_class), __FILE__, __LINE__, (_message_format), ##__VA_ARGS__) |
| 830 | |
| 831 | /*! |
| 832 | @brief |
| 833 | Appends an error cause to the current thread's error from any |
| 834 | function. |
| 835 | |
| 836 | Use this function when you cannot use |
| 837 | bt_current_thread_error_append_cause_from_component(), |
| 838 | bt_current_thread_error_append_cause_from_message_iterator(), |
| 839 | or bt_current_thread_error_append_cause_from_component_class(). |
| 840 | |
| 841 | This this a <code>printf()</code>-like function starting from the |
| 842 | format string parameter \bt_p{message_format}. |
| 843 | |
| 844 | @param[in] module_name |
| 845 | Module name of the error cause to append. |
| 846 | @param[in] file_name |
| 847 | Name of the source file containing the method which appends the |
| 848 | error cause. |
| 849 | @param[in] line_number |
| 850 | Line number of the statement which appends the error cause. |
| 851 | @param[in] message_format |
| 852 | Format string which specifies how the function converts the |
| 853 | subsequent arguments (like <code>printf()</code>). |
| 854 | |
| 855 | @retval #BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_OK |
| 856 | Success. |
| 857 | @retval #BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_MEMORY_ERROR |
| 858 | Out of memory. |
| 859 | |
| 860 | @bt_pre_not_null{module_name} |
| 861 | @bt_pre_not_null{file_name} |
| 862 | @bt_pre_not_null{message_format} |
| 863 | @bt_pre_valid_fmt{message_format} |
| 864 | |
| 865 | @post |
| 866 | <strong>On success</strong>, the number of error causes in the |
| 867 | current thread's error is incremented. |
| 868 | |
| 869 | @sa BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN() — |
| 870 | Calls this function with \c __FILE__ and \c __LINE__ as the |
| 871 | \bt_p{file_name} and \bt_p{line_number} parameters. |
| 872 | */ |
| 873 | extern __BT_ATTR_FORMAT_PRINTF(4, 5) |
| 874 | bt_current_thread_error_append_cause_status |
| 875 | bt_current_thread_error_append_cause_from_unknown( |
| 876 | const char *module_name, const char *file_name, |
| 877 | uint64_t line_number, |
| 878 | const char *message_format, ...) __BT_NOEXCEPT; |
| 879 | |
| 880 | /*! |
| 881 | @brief |
| 882 | Appends an error cause to the current thread's error from any |
| 883 | function using \c __FILE__ and \c __LINE__ as the source |
| 884 | file name and line number. |
| 885 | |
| 886 | Use this function when you cannot use |
| 887 | BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT(), |
| 888 | BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_MESSAGE_ITERATOR(), |
| 889 | or BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT_CLASS(). |
| 890 | |
| 891 | This macro calls bt_current_thread_error_append_cause_from_unknown() |
| 892 | with \c __FILE__ and \c __LINE__ as its |
| 893 | \bt_p{file_name} and \bt_p{line_number} parameters. |
| 894 | */ |
| 895 | #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(_module_name, _message_format, ...) \ |
| 896 | bt_current_thread_error_append_cause_from_unknown( \ |
| 897 | (_module_name), __FILE__, __LINE__, (_message_format), ##__VA_ARGS__) |
| 898 | |
| 899 | /*! @} */ |
| 900 | |
| 901 | /*! |
| 902 | @name Error |
| 903 | @{ |
| 904 | */ |
| 905 | |
| 906 | /*! |
| 907 | @brief |
| 908 | Returns the number of error causes contained in the error |
| 909 | \bt_p{error}. |
| 910 | |
| 911 | @param[in] error |
| 912 | Error of which to get the number of contained error causes. |
| 913 | |
| 914 | @returns |
| 915 | Number of contained error causes in \bt_p{error}. |
| 916 | |
| 917 | @bt_pre_not_null{error} |
| 918 | */ |
| 919 | extern |
| 920 | uint64_t bt_error_get_cause_count(const bt_error *error) __BT_NOEXCEPT; |
| 921 | |
| 922 | /*! |
| 923 | @brief |
| 924 | Borrows the error cause at index \bt_p{index} from the |
| 925 | error \bt_p{error}. |
| 926 | |
| 927 | @param[in] error |
| 928 | Error from which to borrow the error cause at index \bt_p{index}. |
| 929 | @param[in] index |
| 930 | Index of the error cause to borrow from \bt_p{error}. |
| 931 | |
| 932 | @returns |
| 933 | @parblock |
| 934 | \em Borrowed reference of the error cause of |
| 935 | \bt_p{error} at index \bt_p{index}. |
| 936 | |
| 937 | The returned pointer remains valid until \bt_p{error} is modified. |
| 938 | @endparblock |
| 939 | |
| 940 | @bt_pre_not_null{error} |
| 941 | @pre |
| 942 | \bt_p{index} is less than the number of error causes in |
| 943 | \bt_p{error} (as returned by bt_error_get_cause_count()). |
| 944 | */ |
| 945 | extern |
| 946 | const bt_error_cause *bt_error_borrow_cause_by_index( |
| 947 | const bt_error *error, uint64_t index) __BT_NOEXCEPT; |
| 948 | |
| 949 | /*! |
| 950 | @brief |
| 951 | Releases (frees) the error \bt_p{error}. |
| 952 | |
| 953 | After you call this function, \bt_p{error} does not exist. |
| 954 | |
| 955 | Take the current thread's error with bt_current_thread_take_error(). |
| 956 | |
| 957 | In <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented programming</a> |
| 958 | terms, calling this function corresponds to catching an |
| 959 | exception and discarding it. |
| 960 | |
| 961 | You can instead move the ownership of \bt_p{error} to the library with |
| 962 | bt_current_thread_move_error(), which, |
| 963 | in object-oriented programming terms, |
| 964 | corresponds to catching an exception and rethrowing it. |
| 965 | |
| 966 | @param[in] error |
| 967 | Error to release (free). |
| 968 | |
| 969 | @bt_pre_not_null{error} |
| 970 | |
| 971 | @post |
| 972 | \bt_p{error} does not exist. |
| 973 | |
| 974 | @sa bt_current_thread_move_error() — |
| 975 | Moves an error's ownership to the library. |
| 976 | */ |
| 977 | extern |
| 978 | void bt_error_release(const bt_error *error) __BT_NOEXCEPT; |
| 979 | |
| 980 | /*! @} */ |
| 981 | |
| 982 | /*! |
| 983 | @name Error cause: common |
| 984 | @{ |
| 985 | */ |
| 986 | |
| 987 | /*! |
| 988 | @brief |
| 989 | Error cause actor type enumerators. |
| 990 | */ |
| 991 | typedef enum bt_error_cause_actor_type { |
| 992 | /*! |
| 993 | @brief |
| 994 | Any function. |
| 995 | */ |
| 996 | BT_ERROR_CAUSE_ACTOR_TYPE_UNKNOWN = 1 << 0, |
| 997 | |
| 998 | /*! |
| 999 | @brief |
| 1000 | Component method. |
| 1001 | */ |
| 1002 | BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT = 1 << 1, |
| 1003 | |
| 1004 | /*! |
| 1005 | @brief |
| 1006 | Component class method. |
| 1007 | */ |
| 1008 | BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS = 1 << 2, |
| 1009 | |
| 1010 | /*! |
| 1011 | @brief |
| 1012 | Message iterator method. |
| 1013 | */ |
| 1014 | BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR = 1 << 3, |
| 1015 | } bt_error_cause_actor_type; |
| 1016 | |
| 1017 | /*! |
| 1018 | @brief |
| 1019 | Returns the actor type enumerator of the error cause |
| 1020 | \bt_p{error_cause}. |
| 1021 | |
| 1022 | @param[in] error_cause |
| 1023 | Error cause of which to get the actor type enumerator. |
| 1024 | |
| 1025 | @returns |
| 1026 | Actor type enumerator of \bt_p{error_cause}. |
| 1027 | |
| 1028 | @bt_pre_not_null{error_cause} |
| 1029 | */ |
| 1030 | extern |
| 1031 | bt_error_cause_actor_type bt_error_cause_get_actor_type( |
| 1032 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1033 | |
| 1034 | /*! |
| 1035 | @brief |
| 1036 | Returns the message of the error cause \bt_p{error_cause}. |
| 1037 | |
| 1038 | @param[in] error_cause |
| 1039 | Error cause of which to get the message. |
| 1040 | |
| 1041 | @returns |
| 1042 | @parblock |
| 1043 | Message of \bt_p{error_cause}. |
| 1044 | |
| 1045 | The returned pointer remains valid as long as the error which |
| 1046 | contains \bt_p{error_cause} exists. |
| 1047 | @endparblock |
| 1048 | |
| 1049 | @bt_pre_not_null{error_cause} |
| 1050 | */ |
| 1051 | extern |
| 1052 | const char *bt_error_cause_get_message( |
| 1053 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1054 | |
| 1055 | /*! |
| 1056 | @brief |
| 1057 | Returns the module name of the error cause \bt_p{error_cause}. |
| 1058 | |
| 1059 | @param[in] error_cause |
| 1060 | Error cause of which to get the module name. |
| 1061 | |
| 1062 | @returns |
| 1063 | @parblock |
| 1064 | Module name of \bt_p{error_cause}. |
| 1065 | |
| 1066 | The returned pointer remains valid as long as the error which |
| 1067 | contains \bt_p{error_cause} exists. |
| 1068 | @endparblock |
| 1069 | |
| 1070 | @bt_pre_not_null{error_cause} |
| 1071 | */ |
| 1072 | extern |
| 1073 | const char *bt_error_cause_get_module_name( |
| 1074 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1075 | |
| 1076 | /*! |
| 1077 | @brief |
| 1078 | Returns the name of the source file which contains the function |
| 1079 | which appended the error cause \bt_p{error_cause} to the |
| 1080 | current thread's error. |
| 1081 | |
| 1082 | @param[in] error_cause |
| 1083 | Error cause of which to get the source file name. |
| 1084 | |
| 1085 | @returns |
| 1086 | @parblock |
| 1087 | Source file name of \bt_p{error_cause}. |
| 1088 | |
| 1089 | The returned pointer remains valid as long as the error which |
| 1090 | contains \bt_p{error_cause} exists. |
| 1091 | @endparblock |
| 1092 | |
| 1093 | @bt_pre_not_null{error_cause} |
| 1094 | */ |
| 1095 | extern |
| 1096 | const char *bt_error_cause_get_file_name( |
| 1097 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1098 | |
| 1099 | /*! |
| 1100 | @brief |
| 1101 | Returns the line number of the statement |
| 1102 | which appended the error cause \bt_p{error_cause} to the |
| 1103 | current thread's error. |
| 1104 | |
| 1105 | @param[in] error_cause |
| 1106 | Error cause of which to get the source statement's line number. |
| 1107 | |
| 1108 | @returns |
| 1109 | Source statement's line number of \bt_p{error_cause}. |
| 1110 | |
| 1111 | @bt_pre_not_null{error_cause} |
| 1112 | */ |
| 1113 | extern |
| 1114 | uint64_t bt_error_cause_get_line_number( |
| 1115 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1116 | |
| 1117 | /*! @} */ |
| 1118 | |
| 1119 | /*! |
| 1120 | @name Error cause with a component actor |
| 1121 | @{ |
| 1122 | */ |
| 1123 | |
| 1124 | /*! |
| 1125 | @brief |
| 1126 | Returns the name of the \bt_comp of which a method |
| 1127 | appended the error cause \bt_p{error_cause} to the current |
| 1128 | thread's error. |
| 1129 | |
| 1130 | @param[in] error_cause |
| 1131 | Error cause of which to get the component name. |
| 1132 | |
| 1133 | @returns |
| 1134 | @parblock |
| 1135 | Component name of \bt_p{error_cause}. |
| 1136 | |
| 1137 | The returned pointer remains valid as long as the error which |
| 1138 | contains \bt_p{error_cause} exists. |
| 1139 | @endparblock |
| 1140 | |
| 1141 | @bt_pre_not_null{error_cause} |
| 1142 | @pre |
| 1143 | The actor type of \bt_p{error_cause} is |
| 1144 | #BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT. |
| 1145 | */ |
| 1146 | extern |
| 1147 | const char *bt_error_cause_component_actor_get_component_name( |
| 1148 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1149 | |
| 1150 | /*! |
| 1151 | @brief |
| 1152 | Returns the \ref api-comp-cls "class" type of the |
| 1153 | \bt_comp of which a method appended the error cause |
| 1154 | \bt_p{error_cause} to the current thread's error. |
| 1155 | |
| 1156 | @param[in] error_cause |
| 1157 | Error cause of which to get the component class type. |
| 1158 | |
| 1159 | @returns |
| 1160 | Component class type of \bt_p{error_cause}. |
| 1161 | |
| 1162 | @bt_pre_not_null{error_cause} |
| 1163 | @pre |
| 1164 | The actor type of \bt_p{error_cause} is |
| 1165 | #BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT. |
| 1166 | */ |
| 1167 | extern |
| 1168 | bt_component_class_type bt_error_cause_component_actor_get_component_class_type( |
| 1169 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1170 | |
| 1171 | /*! |
| 1172 | @brief |
| 1173 | Returns the \ref api-comp-cls "class" name of the |
| 1174 | \bt_comp of which a method appended the error cause |
| 1175 | \bt_p{error_cause} to the current thread's error. |
| 1176 | |
| 1177 | @param[in] error_cause |
| 1178 | Error cause of which to get the component class name. |
| 1179 | |
| 1180 | @returns |
| 1181 | @parblock |
| 1182 | Component class name of \bt_p{error_cause}. |
| 1183 | |
| 1184 | The returned pointer remains valid as long as the error which |
| 1185 | contains \bt_p{error_cause} exists. |
| 1186 | @endparblock |
| 1187 | |
| 1188 | @bt_pre_not_null{error_cause} |
| 1189 | @pre |
| 1190 | The actor type of \bt_p{error_cause} is |
| 1191 | #BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT. |
| 1192 | */ |
| 1193 | extern |
| 1194 | const char *bt_error_cause_component_actor_get_component_class_name( |
| 1195 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1196 | |
| 1197 | /*! |
| 1198 | @brief |
| 1199 | Returns the name of the \bt_plugin which provides the |
| 1200 | \ref api-comp-cls "class" of the \bt_comp of which a method |
| 1201 | appended the error cause \bt_p{error_cause} to the |
| 1202 | current thread's error. |
| 1203 | |
| 1204 | This function returns \c NULL if no plugin provides the error cause's |
| 1205 | component class. |
| 1206 | |
| 1207 | @param[in] error_cause |
| 1208 | Error cause of which to get the plugin name. |
| 1209 | |
| 1210 | @returns |
| 1211 | @parblock |
| 1212 | Plugin name of \bt_p{error_cause}, or \c NULL if no plugin |
| 1213 | provides the component class of \bt_p{error_cause}. |
| 1214 | |
| 1215 | The returned pointer remains valid as long as the error which |
| 1216 | contains \bt_p{error_cause} exists. |
| 1217 | @endparblock |
| 1218 | |
| 1219 | @bt_pre_not_null{error_cause} |
| 1220 | @pre |
| 1221 | The actor type of \bt_p{error_cause} is |
| 1222 | #BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT. |
| 1223 | */ |
| 1224 | extern |
| 1225 | const char *bt_error_cause_component_actor_get_plugin_name( |
| 1226 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1227 | |
| 1228 | /*! @} */ |
| 1229 | |
| 1230 | /*! |
| 1231 | @name Error cause with a message iterator actor |
| 1232 | @{ |
| 1233 | */ |
| 1234 | |
| 1235 | /*! |
| 1236 | @brief |
| 1237 | Returns the name of the \bt_oport from which was created |
| 1238 | the message iterator of which the method |
| 1239 | appended the error cause \bt_p{error_cause} to the current |
| 1240 | thread's error. |
| 1241 | |
| 1242 | @param[in] error_cause |
| 1243 | Error cause of which to get the output port name. |
| 1244 | |
| 1245 | @returns |
| 1246 | @parblock |
| 1247 | Output port name of \bt_p{error_cause}. |
| 1248 | |
| 1249 | The returned pointer remains valid as long as the error which |
| 1250 | contains \bt_p{error_cause} exists. |
| 1251 | @endparblock |
| 1252 | |
| 1253 | @bt_pre_not_null{error_cause} |
| 1254 | @pre |
| 1255 | The actor type of \bt_p{error_cause} is |
| 1256 | #BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR. |
| 1257 | */ |
| 1258 | extern |
| 1259 | const char *bt_error_cause_message_iterator_actor_get_component_output_port_name( |
| 1260 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1261 | |
| 1262 | /*! |
| 1263 | @brief |
| 1264 | Returns the name of the \bt_comp of which a message iterator method |
| 1265 | appended the error cause \bt_p{error_cause} to the current |
| 1266 | thread's error. |
| 1267 | |
| 1268 | @param[in] error_cause |
| 1269 | Error cause of which to get the component name. |
| 1270 | |
| 1271 | @returns |
| 1272 | @parblock |
| 1273 | Component name of \bt_p{error_cause}. |
| 1274 | |
| 1275 | The returned pointer remains valid as long as the error which |
| 1276 | contains \bt_p{error_cause} exists. |
| 1277 | @endparblock |
| 1278 | |
| 1279 | @bt_pre_not_null{error_cause} |
| 1280 | @pre |
| 1281 | The actor type of \bt_p{error_cause} is |
| 1282 | #BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR. |
| 1283 | */ |
| 1284 | extern |
| 1285 | const char *bt_error_cause_message_iterator_actor_get_component_name( |
| 1286 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1287 | |
| 1288 | /*! |
| 1289 | @brief |
| 1290 | Returns the \ref api-comp-cls "class" type of the |
| 1291 | \bt_comp of which a message iterator method appended the error cause |
| 1292 | \bt_p{error_cause} to the current thread's error. |
| 1293 | |
| 1294 | @param[in] error_cause |
| 1295 | Error cause of which to get the component class type. |
| 1296 | |
| 1297 | @returns |
| 1298 | Component class type of \bt_p{error_cause}. |
| 1299 | |
| 1300 | @bt_pre_not_null{error_cause} |
| 1301 | @pre |
| 1302 | The actor type of \bt_p{error_cause} is |
| 1303 | #BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR. |
| 1304 | */ |
| 1305 | extern |
| 1306 | bt_component_class_type |
| 1307 | bt_error_cause_message_iterator_actor_get_component_class_type( |
| 1308 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1309 | |
| 1310 | /*! |
| 1311 | @brief |
| 1312 | Returns the \ref api-comp-cls "class" name of the |
| 1313 | \bt_comp of which a message iterator method appended the error cause |
| 1314 | \bt_p{error_cause} to the current thread's error. |
| 1315 | |
| 1316 | @param[in] error_cause |
| 1317 | Error cause of which to get the component class name. |
| 1318 | |
| 1319 | @returns |
| 1320 | @parblock |
| 1321 | Component class name of \bt_p{error_cause}. |
| 1322 | |
| 1323 | The returned pointer remains valid as long as the error which |
| 1324 | contains \bt_p{error_cause} exists. |
| 1325 | @endparblock |
| 1326 | |
| 1327 | @bt_pre_not_null{error_cause} |
| 1328 | @pre |
| 1329 | The actor type of \bt_p{error_cause} is |
| 1330 | #BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR. |
| 1331 | */ |
| 1332 | extern |
| 1333 | const char *bt_error_cause_message_iterator_actor_get_component_class_name( |
| 1334 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1335 | |
| 1336 | /*! |
| 1337 | @brief |
| 1338 | Returns the name of the \bt_plugin which provides the |
| 1339 | \ref api-comp-cls "class" of the \bt_comp of which a |
| 1340 | message iterator method |
| 1341 | appended the error cause \bt_p{error_cause} to the |
| 1342 | current thread's error. |
| 1343 | |
| 1344 | This function returns \c NULL if no plugin provides the error cause's |
| 1345 | component class. |
| 1346 | |
| 1347 | @param[in] error_cause |
| 1348 | Error cause of which to get the plugin name. |
| 1349 | |
| 1350 | @returns |
| 1351 | @parblock |
| 1352 | Plugin name of \bt_p{error_cause}, or \c NULL if no plugin |
| 1353 | provides the component class of \bt_p{error_cause}. |
| 1354 | |
| 1355 | The returned pointer remains valid as long as the error which |
| 1356 | contains \bt_p{error_cause} exists. |
| 1357 | @endparblock |
| 1358 | |
| 1359 | @bt_pre_not_null{error_cause} |
| 1360 | @pre |
| 1361 | The actor type of \bt_p{error_cause} is |
| 1362 | #BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR. |
| 1363 | */ |
| 1364 | extern |
| 1365 | const char *bt_error_cause_message_iterator_actor_get_plugin_name( |
| 1366 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1367 | |
| 1368 | /*! @} */ |
| 1369 | |
| 1370 | /*! |
| 1371 | @name Error cause with a component class actor |
| 1372 | @{ |
| 1373 | */ |
| 1374 | |
| 1375 | /*! |
| 1376 | @brief |
| 1377 | Returns the name of the \bt_comp_cls |
| 1378 | of which a method appended the error cause |
| 1379 | \bt_p{error_cause} to the current thread's error. |
| 1380 | |
| 1381 | @param[in] error_cause |
| 1382 | Error cause of which to get the component class name. |
| 1383 | |
| 1384 | @returns |
| 1385 | Component class name of \bt_p{error_cause}. |
| 1386 | |
| 1387 | @bt_pre_not_null{error_cause} |
| 1388 | @pre |
| 1389 | The actor type of \bt_p{error_cause} is |
| 1390 | #BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS. |
| 1391 | */ |
| 1392 | extern |
| 1393 | bt_component_class_type |
| 1394 | bt_error_cause_component_class_actor_get_component_class_type( |
| 1395 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1396 | |
| 1397 | /*! |
| 1398 | @brief |
| 1399 | Returns the name of the \bt_comp_cls |
| 1400 | of which a method appended the error cause |
| 1401 | \bt_p{error_cause} to the current thread's error. |
| 1402 | |
| 1403 | @param[in] error_cause |
| 1404 | Error cause of which to get the component class name. |
| 1405 | |
| 1406 | @returns |
| 1407 | @parblock |
| 1408 | Component class name of \bt_p{error_cause}. |
| 1409 | |
| 1410 | The returned pointer remains valid as long as the error which |
| 1411 | contains \bt_p{error_cause} exists. |
| 1412 | @endparblock |
| 1413 | |
| 1414 | @bt_pre_not_null{error_cause} |
| 1415 | @pre |
| 1416 | The actor type of \bt_p{error_cause} is |
| 1417 | #BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS. |
| 1418 | */ |
| 1419 | extern |
| 1420 | const char *bt_error_cause_component_class_actor_get_component_class_name( |
| 1421 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1422 | |
| 1423 | /*! |
| 1424 | @brief |
| 1425 | Returns the name of the \bt_plugin which provides the |
| 1426 | \bt_comp_cls of which a method |
| 1427 | appended the error cause \bt_p{error_cause} to the |
| 1428 | current thread's error. |
| 1429 | |
| 1430 | This function returns \c NULL if no plugin provides the error cause's |
| 1431 | component class. |
| 1432 | |
| 1433 | @param[in] error_cause |
| 1434 | Error cause of which to get the plugin name. |
| 1435 | |
| 1436 | @returns |
| 1437 | @parblock |
| 1438 | Plugin name of \bt_p{error_cause}, or \c NULL if no plugin |
| 1439 | provides the component class of \bt_p{error_cause}. |
| 1440 | |
| 1441 | The returned pointer remains valid as long as the error which |
| 1442 | contains \bt_p{error_cause} exists. |
| 1443 | @endparblock |
| 1444 | |
| 1445 | @bt_pre_not_null{error_cause} |
| 1446 | @pre |
| 1447 | The actor type of \bt_p{error_cause} is |
| 1448 | #BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS. |
| 1449 | */ |
| 1450 | extern |
| 1451 | const char *bt_error_cause_component_class_actor_get_plugin_name( |
| 1452 | const bt_error_cause *error_cause) __BT_NOEXCEPT; |
| 1453 | |
| 1454 | /*! @} */ |
| 1455 | |
| 1456 | /*! @} */ |
| 1457 | |
| 1458 | #ifdef __cplusplus |
| 1459 | } |
| 1460 | #endif |
| 1461 | |
| 1462 | #endif /* BABELTRACE2_ERROR_REPORTING_H */ |