Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
27 changes: 27 additions & 0 deletions src/lib/support/CodeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,33 @@
} \
} while (false)

/**
* @def ReturnErrorVariantOnFailure(expr)
*
* @brief
* This is for use when the calling function returns a Variant type. It returns a CHIP_ERROR variant with the corresponding error
* code if the expression returns an error.
*
* Example usage:
*
* @code
* ReturnErrorVariantOnFailure(NextStep, ParseSigma1(tlvReader, parsedSigma1));
* @endcode
*
* @param[in] variantType The Variant type that the calling function returns.
* @param[in] expr An expression to be tested.

*/
#define ReturnErrorVariantOnFailure(variantType, expr) \
do \
{ \
auto __err = (expr); \
if (!::chip::ChipError::IsSuccess(__err)) \
{ \
return variantType::Create<CHIP_ERROR>(__err); \
} \
} while (false)

/**
* @def ReturnLogErrorOnFailure(expr)
*
Expand Down
Loading
Loading