Skip to content

Commit 4ef4438

Browse files
committed
Add a macro for dynamic global IM status codes in chip_error
1 parent da6b870 commit 4ef4438

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/app/codegen-data-model/CodegenDataModel_Read.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ CHIP_ERROR CodegenDataModel::ReadAttribute(const InteractionModel::ReadAttribute
362362

363363
if (status != Protocols::InteractionModel::Status::Success)
364364
{
365-
return CHIP_SDK_ERROR(ChipError::SdkPart::kIMGlobalStatus, to_underlying(status));
365+
return CHIP_ERROR_IM_GLOBAL_STATUS_VALUE(status);
366366
}
367367

368368
return EncodeEmberValue(gEmberAttributeIOBufferSpan, attributeMetadata, encoder);

src/lib/core/CHIPError.h

+9
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,15 @@ using CHIP_ERROR = ::chip::ChipError;
439439
CHIP_SDK_ERROR(::chip::ChipError::SdkPart::kIMGlobalStatus, \
440440
::chip::to_underlying(::chip::Protocols::InteractionModel::Status::type))
441441

442+
// Defines a runtime-value for a chip-error.
443+
#if CHIP_CONFIG_ERROR_SOURCE
444+
#define CHIP_ERROR_IM_GLOBAL_STATUS_VALUE(status_value) \
445+
::chip::ChipError(::chip::ChipError::SdkPart::kIMGlobalStatus, ::chip::to_underlying(status_value), __FILE__, __LINE__)
446+
#else
447+
#define CHIP_ERROR_IM_GLOBAL_STATUS_VALUE(status_value) \
448+
::chip::ChipError(::chip::ChipError::SdkPart::kIMGlobalStatus, ::chip::to_underlying(status_value))
449+
#endif // CHIP_CONFIG_ERROR_SOURCE
450+
442451
//
443452
// type must be a compile-time constant as mandated by CHIP_SDK_ERROR.
444453
//

0 commit comments

Comments
 (0)