Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions include/rcutils/error_handling.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,24 @@ rcutils_set_error_state(const char * error_string, const char * file, size_t lin
} \
} while (0)

/// Indicate that the function intends to set an error message and return an error value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add some comment mentioning that this is part of the fault injection so people understand its intended purpose.

/**
* \def RCUTILS_CAN_SET_MSG_AND_RETURN_WITH_ERROR_OF
* Indicating macro similar to RCUTILS_CAN_RETURN_WITH_ERROR_OF, that also sets an error
* message.
*
* For now, this macro simply relies on `RCUTILS_CAN_FAIL_WITH` to set a generic error
* message and return the given `error_return_value` if fault injection is enabled.
*
* \param error_return_value the value returned as a result of a given error.
*/
#define RCUTILS_CAN_SET_MSG_AND_RETURN_WITH_ERROR_OF(error_return_value) \
RCUTILS_CAN_FAIL_WITH( \
{ \
RCUTILS_SET_ERROR_MSG("Injecting " RCUTILS_STRINGIFY(error_return_value)); \
return error_return_value; \
})

/// Return `true` if the error is set, otherwise `false`.
RCUTILS_PUBLIC
RCUTILS_WARN_UNUSED
Expand Down