Skip to content

Commit

Permalink
Add error mapping for NOT_FOUND on Darwin. (#14721)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored Feb 3, 2022
1 parent 8881290 commit 2294bcc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/CHIPError.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef NS_ERROR_ENUM(CHIPErrorDomain, CHIPErrorCode){
CHIPErrorCodeUnsupportedAttribute = 0x86,
CHIPErrorCodeConstraintError = 0x87,
CHIPErrorCodeUnsupportedWrite = 0x88,
CHIPErrorCodeNotFound = 0x8B,
CHIPErrorCodeInvalidDataType = 0x8D,
CHIPErrorCodeUnsupportedCluster = 0xC3,
};
Expand Down
8 changes: 8 additions & 0 deletions src/darwin/Framework/CHIP/CHIPError.mm
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ + (NSError *)errorForZCLErrorCode:(uint8_t)errorCode
errorWithDomain:CHIPErrorDomain
code:CHIPErrorCodeUnsupportedWrite
userInfo:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"Attempt to write read-only attribute.", nil) }];
case EMBER_ZCL_STATUS_NOT_FOUND:
return [NSError errorWithDomain:CHIPErrorDomain
code:CHIPErrorCodeNotFound
userInfo:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"Data not found.", nil) }];
case EMBER_ZCL_STATUS_INVALID_DATA_TYPE:
return [NSError
errorWithDomain:CHIPErrorDomain
Expand Down Expand Up @@ -207,6 +211,10 @@ + (uint8_t)errorToZCLErrorCode:(NSError * _Nullable)error
return EMBER_ZCL_STATUS_CONSTRAINT_ERROR;
case CHIPErrorCodeUnsupportedWrite:
return EMBER_ZCL_STATUS_UNSUPPORTED_WRITE;
case CHIPErrorCodeNotFound:
return EMBER_ZCL_STATUS_NOT_FOUND;
case CHIPErrorCodeInvalidDataType:
return EMBER_ZCL_STATUS_INVALID_DATA_TYPE;
case CHIPErrorCodeUnsupportedCluster:
return EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER;
default:
Expand Down
2 changes: 2 additions & 0 deletions src/darwin/Framework/CHIPTests/CHIPErrorTestUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ + (uint8_t)errorToZCLErrorCode:(NSError * _Nullable)error
return EMBER_ZCL_STATUS_CONSTRAINT_ERROR;
case CHIPErrorCodeUnsupportedWrite:
return EMBER_ZCL_STATUS_UNSUPPORTED_WRITE;
case CHIPErrorCodeNotFound:
return EMBER_ZCL_STATUS_NOT_FOUND;
case CHIPErrorCodeInvalidDataType:
return EMBER_ZCL_STATUS_INVALID_DATA_TYPE;
case CHIPErrorCodeUnsupportedCluster:
Expand Down

0 comments on commit 2294bcc

Please sign in to comment.