Skip to content

Commit

Permalink
Add Darwin error mapping for CHIP_ERROR_TIMEOUT. (#15980)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored Mar 9, 2022
1 parent f3b5ce5 commit b146c95
Show file tree
Hide file tree
Showing 2 changed files with 9 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 @@ -49,6 +49,7 @@ typedef NS_ERROR_ENUM(CHIPErrorDomain, CHIPErrorCode){
CHIPErrorCodeInvalidState = 6,
CHIPErrorCodeWrongAddressType = 7,
CHIPErrorCodeIntegrityCheckFailed = 8,
CHIPErrorCodeTimeout = 9,
};
// clang-format on

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 @@ -77,6 +77,12 @@ + (NSError *)errorForCHIPErrorCode:(CHIP_ERROR)errorCode
userInfo:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"Integrity check failed.", nil) }];
}

if (errorCode == CHIP_ERROR_TIMEOUT) {
return [NSError errorWithDomain:CHIPErrorDomain
code:CHIPErrorCodeTimeout
userInfo:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"Transaction timed out.", nil) }];
}

return [NSError errorWithDomain:CHIPErrorDomain
code:CHIPErrorCodeGeneralError
userInfo:@{
Expand Down Expand Up @@ -237,6 +243,8 @@ + (CHIP_ERROR)errorToCHIPErrorCode:(NSError * _Nullable)error
return CHIP_ERROR_INCORRECT_STATE;
case CHIPErrorCodeIntegrityCheckFailed:
return CHIP_ERROR_INTEGRITY_CHECK_FAILED;
case CHIPErrorCodeTimeout:
return CHIP_ERROR_TIMEOUT;
default:
return CHIP_ERROR_INTERNAL;
}
Expand Down

0 comments on commit b146c95

Please sign in to comment.