Skip to content

Commit

Permalink
Add missing CHIP error codes into CHIPError.cpp/TestCHIPErrorStr.cpp …
Browse files Browse the repository at this point in the history
…and fix duplicates (#17414)

* Add error codes from CHIPError.h that are missing from CHIPError.cpp and TestCHIPErrorStr.cpp

* Add events missing in string translation and kTestElements[]

* Remove duplicate defines due to merge error.

* Fix merge conflicts.

* Code review changes.
  • Loading branch information
isiu-apple authored and pull[bot] committed Jun 27, 2023
1 parent ebdc101 commit 70ef65a
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 51 deletions.
40 changes: 35 additions & 5 deletions src/lib/core/CHIPError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err)
#if !CHIP_CONFIG_SHORT_ERROR_STR
switch (err.AsInteger())
{
case CHIP_ERROR_TOO_MANY_CONNECTIONS.AsInteger():
desc = "Too many connections";
break;
case CHIP_ERROR_SENDING_BLOCKED.AsInteger():
desc = "Sending blocked";
break;
Expand Down Expand Up @@ -407,6 +404,15 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err)
case CHIP_ERROR_INVALID_FABRIC_ID.AsInteger():
desc = "Invalid Fabric Id";
break;
case CHIP_ERROR_TOO_MANY_CONNECTIONS.AsInteger():
desc = "Too many connections";
break;
case CHIP_ERROR_SHUT_DOWN.AsInteger():
desc = "The operation was cancelled because a shut down was initiated";
break;
case CHIP_ERROR_CANCELLED.AsInteger():
desc = "The operation has been cancelled";
break;
case CHIP_ERROR_DRBG_ENTROPY_SOURCE_FAILED.AsInteger():
desc = "DRBG entropy source failed to generate entropy data";
break;
Expand Down Expand Up @@ -620,12 +626,21 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err)
case CHIP_ERROR_DUPLICATE_MESSAGE_RECEIVED.AsInteger():
desc = "Duplicate message received";
break;
case CHIP_ERROR_INVALID_PUBLIC_KEY.AsInteger():
desc = "Invalid public key";
break;
case CHIP_ERROR_FABRIC_MISMATCH_ON_ICA.AsInteger():
desc = "Fabric mismatch on ICA";
break;
case CHIP_ERROR_MESSAGE_COUNTER_OUT_OF_WINDOW.AsInteger():
desc = "Message id out of window";
break;
case CHIP_ERROR_REBOOT_SIGNAL_RECEIVED.AsInteger():
desc = "Termination signal is received";
break;
case CHIP_ERROR_NO_SHARED_TRUSTED_ROOT.AsInteger():
desc = "No shared trusted root";
break;
case CHIP_ERROR_IM_STATUS_CODE_RECEIVED.AsInteger():
desc = "Interaction Model Error";
break;
Expand Down Expand Up @@ -668,12 +683,15 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err)
case CHIP_ERROR_IM_MALFORMED_DATA_VERSION_FILTER_IB.AsInteger():
desc = "Malformed Interaction Model Data Version Filter IB";
break;
case CHIP_ERROR_IM_MALFORMED_STATUS_RESPONSE_MESSAGE.AsInteger():
desc = "Malformed Interaction Model Status Response Message";
case CHIP_ERROR_NOT_FOUND.AsInteger():
desc = "The item referenced in the function call was not found";
break;
case CHIP_ERROR_IM_MALFORMED_TIMED_REQUEST_MESSAGE.AsInteger():
desc = "Malformed Interaction Model Timed Request Message";
break;
case CHIP_ERROR_INVALID_FILE_IDENTIFIER.AsInteger():
desc = "The file identifier, encoded in the first few bytes of a processed file, has unexpected value";
break;
case CHIP_ERROR_BUSY.AsInteger():
desc = "The Resource is busy and cannot process the request";
break;
Expand All @@ -683,6 +701,18 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err)
case CHIP_ERROR_PROVIDER_LIST_EXHAUSTED.AsInteger():
desc = "The provider list has been exhausted";
break;
case CHIP_ERROR_ANOTHER_COMMISSIONING_IN_PROGRESS.AsInteger():
desc = "Another commissioning in progress";
break;
case CHIP_ERROR_INVALID_SCHEME_PREFIX.AsInteger():
desc = "The scheme field contains an invalid prefix";
break;
case CHIP_ERROR_MISSING_URI_SEPARATOR.AsInteger():
desc = "The URI separator is missing";
break;
case CHIP_ERROR_IM_MALFORMED_STATUS_RESPONSE_MESSAGE.AsInteger():
desc = "Malformed Interaction Model Status Response Message";
break;
}
#endif // !CHIP_CONFIG_SHORT_ERROR_STR

Expand Down
90 changes: 45 additions & 45 deletions src/lib/core/CHIPError.h
Original file line number Diff line number Diff line change
Expand Up @@ -1472,15 +1472,15 @@ using CHIP_ERROR = ::chip::ChipError;
* @brief
* The operation cancelled because a shut down was initiated
*/
#define CHIP_ERROR_SHUT_DOWN CHIP_CORE_ERROR(0x73)
#define CHIP_ERROR_SHUT_DOWN CHIP_CORE_ERROR(0x73)

/**
* @def CHIP_ERROR_SHUT_DOWN
* @def CHIP_ERROR_CANCELLED
*
* @brief
* The operation has been cancelled, generally by calling a cancel/abort request.
*/
#define CHIP_ERROR_CANCELLED CHIP_CORE_ERROR(0x74)
#define CHIP_ERROR_CANCELLED CHIP_CORE_ERROR(0x74)

/**
* @def CHIP_ERROR_DRBG_ENTROPY_SOURCE_FAILED
Expand Down Expand Up @@ -2206,7 +2206,7 @@ using CHIP_ERROR = ::chip::ChipError;
#define CHIP_ERROR_IM_MALFORMED_INVOKE_RESPONSE_IB CHIP_CORE_ERROR(0xcc)

/**
* @def CHIP_ERROR_IM_MALFORMED_INVOKE_RESPONSE_MESSAGE
* @def CHIP_ERROR_IM_MALFORMED_INVOKE_REQUEST_MESSAGE
*
* @brief
* The InvokeResponseMessage is malformed: it either does not contain
Expand Down Expand Up @@ -2286,23 +2286,14 @@ using CHIP_ERROR = ::chip::ChipError;
*/
#define CHIP_ERROR_IM_MALFORMED_EVENT_REPORT_IB CHIP_CORE_ERROR(0xd5)

/*
* @def CHIP_ERROR_ANOTHER_COMMISSIONING_IN_PROGRESS
*
* @brief
* Indicates that the commissioning window on the device is already open, and another
* commissioning is in progress
*/
#define CHIP_ERROR_ANOTHER_COMMISSIONING_IN_PROGRESS CHIP_CORE_ERROR(0xd6)

/**
* @def CHIP_ERROR_IM_MALFORMED_CLUSTER_PATH_IB
*
* @brief
* The ClusterPathIB is malformed: it either does not contain
* the required elements
*/
#define CHIP_ERROR_IM_MALFORMED_CLUSTER_PATH_IB CHIP_CORE_ERROR(0xd6)
#define CHIP_ERROR_IM_MALFORMED_CLUSTER_PATH_IB CHIP_CORE_ERROR(0xd6)

/**
* @def CHIP_ERROR_IM_MALFORMED_DATA_VERSION_FILTER_IB
Expand All @@ -2322,71 +2313,80 @@ using CHIP_ERROR = ::chip::ChipError;
#define CHIP_ERROR_NOT_FOUND CHIP_CORE_ERROR(0xd8)

/**
* @def CHIP_ERROR_INVALID_SCHEME_PREFIX
* @def CHIP_ERROR_IM_MALFORMED_TIMED_REQUEST_MESSAGE
*
* @brief
* The scheme field contains an invalid prefix
* The Attribute DataElement is malformed: it either does not contain
* the required elements
*/
#define CHIP_ERROR_INVALID_SCHEME_PREFIX CHIP_CORE_ERROR(0xd6)
#define CHIP_ERROR_IM_MALFORMED_TIMED_REQUEST_MESSAGE CHIP_CORE_ERROR(0xd9)

/**
* @def CHIP_ERROR_MISSING_URI_SEPARATOR
* @def CHIP_ERROR_INVALID_FILE_IDENTIFIER
*
* @brief
* The URI separator is missing
* The file identifier, encoded in the first few bytes of a processed file,
* has unexpected value.
*/
#define CHIP_ERROR_MISSING_URI_SEPARATOR CHIP_CORE_ERROR(0xd7)
#define CHIP_ERROR_INVALID_FILE_IDENTIFIER CHIP_CORE_ERROR(0xda)

/**
* @def CHIP_ERROR_IM_MALFORMED_STATUS_RESPONSE_MESSAGE
* @def CHIP_ERROR_BUSY
*
* @brief
* The Attribute DataElement is malformed: it either does not contain
* the required elements
* The Resource is busy and cannot process the request. Trying again might work.
*/
#define CHIP_ERROR_IM_MALFORMED_STATUS_RESPONSE_MESSAGE CHIP_CORE_ERROR(0xd8)
#define CHIP_ERROR_BUSY CHIP_CORE_ERROR(0xdb)

/**
* @def CHIP_ERROR_IM_MALFORMED_TIMED_REQUEST_MESSAGE
*
* @brief
* The Attribute DataElement is malformed: it either does not contain
* the required elements
*/
#define CHIP_ERROR_IM_MALFORMED_TIMED_REQUEST_MESSAGE CHIP_CORE_ERROR(0xd9)
* @def CHIP_ERROR_MAX_RETRY_EXCEEDED
*
* @brief
* The maximum retry limit has been exceeded.
*/
#define CHIP_ERROR_MAX_RETRY_EXCEEDED CHIP_CORE_ERROR(0xdc)

/**
* @def CHIP_ERROR_INVALID_FILE_IDENTIFIER
/**
* @def CHIP_ERROR_PROVIDER_LIST_EXHAUSTED
*
* @brief
* The provider list has been exhausted.
*/
#define CHIP_ERROR_PROVIDER_LIST_EXHAUSTED CHIP_CORE_ERROR(0xdd)

/*
* @def CHIP_ERROR_ANOTHER_COMMISSIONING_IN_PROGRESS
*
* @brief
* The file identifier, encoded in the first few bytes of a processed file,
* has unexpected value.
* Indicates that the commissioning window on the device is already open, and another
* commissioning is in progress
*/
#define CHIP_ERROR_INVALID_FILE_IDENTIFIER CHIP_CORE_ERROR(0xda)
#define CHIP_ERROR_ANOTHER_COMMISSIONING_IN_PROGRESS CHIP_CORE_ERROR(0xde)

/**
* @def CHIP_ERROR_BUSY
* @def CHIP_ERROR_INVALID_SCHEME_PREFIX
*
* @brief
* The Resource is busy and cannot process the request. Trying again might work.
* The scheme field contains an invalid prefix
*/
#define CHIP_ERROR_BUSY CHIP_CORE_ERROR(0xdb)
#define CHIP_ERROR_INVALID_SCHEME_PREFIX CHIP_CORE_ERROR(0xdf)

/**
* @def CHIP_ERROR_MAX_RETRY_EXCEEDED
* @def CHIP_ERROR_MISSING_URI_SEPARATOR
*
* @brief
* The maximum retry limit has been exceeded.
* The URI separator is missing
*/
#define CHIP_ERROR_MAX_RETRY_EXCEEDED CHIP_CORE_ERROR(0xdc)
#define CHIP_ERROR_MISSING_URI_SEPARATOR CHIP_CORE_ERROR(0xe0)

/**
* @def CHIP_ERROR_PROVIDER_LIST_EXHAUSTED
* @def CHIP_ERROR_IM_MALFORMED_STATUS_RESPONSE_MESSAGE
*
* @brief
* The provider list has been exhausted.
* The Attribute DataElement is malformed: it either does not contain
* the required elements
*/
#define CHIP_ERROR_PROVIDER_LIST_EXHAUSTED CHIP_CORE_ERROR(0xdd)
#define CHIP_ERROR_IM_MALFORMED_STATUS_RESPONSE_MESSAGE CHIP_CORE_ERROR(0xe1)

/**
* @}
Expand Down
39 changes: 38 additions & 1 deletion src/lib/core/tests/TestCHIPErrorStr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ using namespace chip;
// clang-format off
static const CHIP_ERROR kTestElements[] =
{
CHIP_ERROR_TOO_MANY_CONNECTIONS,
CHIP_ERROR_SENDING_BLOCKED,
CHIP_ERROR_CONNECTION_ABORTED,
CHIP_ERROR_INCORRECT_STATE,
Expand All @@ -59,6 +58,7 @@ static const CHIP_ERROR kTestElements[] =
CHIP_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER,
CHIP_ERROR_NO_CONNECTION_HANDLER,
CHIP_ERROR_TOO_MANY_PEER_NODES,
CHIP_ERROR_SENTINEL,
CHIP_ERROR_NO_MEMORY,
CHIP_ERROR_NO_MESSAGE_HANDLER,
CHIP_ERROR_MESSAGE_INCOMPLETE,
Expand Down Expand Up @@ -162,6 +162,9 @@ static const CHIP_ERROR kTestElements[] =
CHIP_ERROR_NO_COMMON_PASE_CONFIGURATIONS,
CHIP_ERROR_UNSOLICITED_MSG_NO_ORIGINATOR,
CHIP_ERROR_INVALID_FABRIC_ID,
CHIP_ERROR_TOO_MANY_CONNECTIONS,
CHIP_ERROR_SHUT_DOWN,
CHIP_ERROR_CANCELLED,
CHIP_ERROR_DRBG_ENTROPY_SOURCE_FAILED,
CHIP_ERROR_TLV_TAG_NOT_FOUND,
CHIP_ERROR_FABRIC_EXISTS,
Expand Down Expand Up @@ -209,6 +212,15 @@ static const CHIP_ERROR kTestElements[] =
CHIP_ERROR_INCONSISTENT_CONDITIONALITY,
CHIP_ERROR_LOCAL_DATA_INCONSISTENT,
CHIP_EVENT_ID_FOUND,
CHIP_ERROR_INTERNAL,
CHIP_ERROR_OPEN_FAILED,
CHIP_ERROR_READ_FAILED,
CHIP_ERROR_WRITE_FAILED,
CHIP_ERROR_DECODE_FAILED,
CHIP_ERROR_SESSION_KEY_SUSPENDED,
CHIP_ERROR_UNSUPPORTED_WIRELESS_REGULATORY_DOMAIN,
CHIP_ERROR_UNSUPPORTED_WIRELESS_OPERATING_LOCATION,
CHIP_ERROR_MDNS_COLLISION,
CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH,
CHIP_ERROR_IM_MALFORMED_EVENT_PATH,
CHIP_ERROR_IM_MALFORMED_COMMAND_PATH,
Expand All @@ -217,9 +229,34 @@ static const CHIP_ERROR kTestElements[] =
CHIP_ERROR_IM_MALFORMED_EVENT_DATA_ELEMENT,
CHIP_ERROR_IM_MALFORMED_STATUS_CODE,
CHIP_ERROR_PEER_NODE_NOT_FOUND,
CHIP_ERROR_HSM,
CHIP_ERROR_IM_STATUS_CODE_RECEIVED,
CHIP_ERROR_IM_MALFORMED_COMMAND_STATUS_IB,
CHIP_ERROR_IM_MALFORMED_INVOKE_RESPONSE_IB,
CHIP_ERROR_IM_MALFORMED_INVOKE_REQUEST_MESSAGE,
CHIP_ERROR_IM_MALFORMED_INVOKE_RESPONSE_MESSAGE,
CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_REPORT_MESSAGE,
CHIP_ERROR_IM_MALFORMED_WRITE_REQUEST_MESSAGE,
CHIP_ERROR_IM_MALFORMED_WRITE_RESPONSE_MESSAGE,
CHIP_ERROR_IM_MALFORMED_READ_REQUEST_MESSAGE,
CHIP_ERROR_IM_MALFORMED_SUBSCRIBE_REQUEST_MESSAGE,
CHIP_ERROR_IM_MALFORMED_SUBSCRIBE_RESPONSE_MESSAGE,
CHIP_ERROR_IM_MALFORMED_EVENT_REPORT_IB,
CHIP_ERROR_IM_MALFORMED_CLUSTER_PATH_IB,
CHIP_ERROR_IM_MALFORMED_DATA_VERSION_FILTER_IB,
CHIP_ERROR_NOT_FOUND,
CHIP_ERROR_IM_MALFORMED_TIMED_REQUEST_MESSAGE,
CHIP_ERROR_INVALID_FILE_IDENTIFIER,
CHIP_ERROR_BUSY,
CHIP_ERROR_MAX_RETRY_EXCEEDED,
CHIP_ERROR_PROVIDER_LIST_EXHAUSTED,
CHIP_ERROR_ANOTHER_COMMISSIONING_IN_PROGRESS,
CHIP_ERROR_INVALID_SCHEME_PREFIX,
CHIP_ERROR_MISSING_URI_SEPARATOR,
CHIP_ERROR_IM_MALFORMED_STATUS_RESPONSE_MESSAGE,
CHIP_ERROR_IM_MALFORMED_TIMED_REQUEST_MESSAGE,
CHIP_ERROR_INVALID_FILE_IDENTIFIER,
CHIP_ERROR_BUSY
};
// clang-format on

Expand Down

0 comments on commit 70ef65a

Please sign in to comment.