Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map CHIP_ERROR_FABRIC_EXISTS into a dedicated Darwin error code. #22271

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 11 additions & 3 deletions src/darwin/Framework/CHIP/MTRError.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ FOUNDATION_EXPORT NSErrorDomain const MTRErrorDomain;
FOUNDATION_EXPORT NSErrorDomain const MTRInteractionErrorDomain;

/**
* ChipErrorDomain contains errors caused by data processing the framework
* MTRErrorDomain contains errors caused by data processing the framework
* itself is performing. These can be caused by invalid values provided to a
* framework API, failure to decode an incoming message, and so forth.
*
* Errors reported by the other side of a Matter interaction use
* MTRInteractionErrorDomain instead.
* This error domain also contains errors that are communicated via success
* responses from a server but mapped to an error on the client.
*
* Errors reported by the server side of a Matter interaction via the normal
* Matter error-reporting mechanisms use MTRInteractionErrorDomain instead.
*/
// clang-format off
typedef NS_ERROR_ENUM(MTRErrorDomain, MTRErrorCode){
Expand All @@ -51,6 +54,11 @@ typedef NS_ERROR_ENUM(MTRErrorDomain, MTRErrorCode){
MTRErrorCodeIntegrityCheckFailed = 8,
MTRErrorCodeTimeout = 9,
MTRErrorCodeBufferTooSmall = 10,
/**
* MTRErrorCodeFabricExists is returned when trying to commission a device
* into a fabric when it's already part of that fabric.
*/
MTRErrorCodeFabricExists = 11,
};
// clang-format on

Expand Down
5 changes: 5 additions & 0 deletions src/darwin/Framework/CHIP/MTRError.mm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ + (NSError *)errorForCHIPErrorCode:(CHIP_ERROR)errorCode
} else if (errorCode == CHIP_ERROR_BUFFER_TOO_SMALL) {
code = MTRErrorCodeBufferTooSmall;
[userInfo addEntriesFromDictionary:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"A buffer is too small.", nil) }];
} else if (errorCode == CHIP_ERROR_FABRIC_EXISTS) {
code = MTRErrorCodeFabricExists;
[userInfo addEntriesFromDictionary:@{
NSLocalizedDescriptionKey : NSLocalizedString(@"The device is already a member of this fabric.", nil)
}];
} else {
code = MTRErrorCodeGeneralError;
[userInfo addEntriesFromDictionary:@{
Expand Down