From d34ade773d27c51f6c6c1a4e16f7a142a7f839ba Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 9 Mar 2022 10:13:27 -0500 Subject: [PATCH] Add Darwin error mapping for CHIP_ERROR_TIMEOUT. (#15980) --- src/darwin/Framework/CHIP/CHIPError.h | 1 + src/darwin/Framework/CHIP/CHIPError.mm | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/darwin/Framework/CHIP/CHIPError.h b/src/darwin/Framework/CHIP/CHIPError.h index ca57cbaa4f3e5e..4f4240e2772839 100644 --- a/src/darwin/Framework/CHIP/CHIPError.h +++ b/src/darwin/Framework/CHIP/CHIPError.h @@ -49,6 +49,7 @@ typedef NS_ERROR_ENUM(CHIPErrorDomain, CHIPErrorCode){ CHIPErrorCodeInvalidState = 6, CHIPErrorCodeWrongAddressType = 7, CHIPErrorCodeIntegrityCheckFailed = 8, + CHIPErrorCodeTimeout = 9, }; // clang-format on diff --git a/src/darwin/Framework/CHIP/CHIPError.mm b/src/darwin/Framework/CHIP/CHIPError.mm index dab3461adde32d..8e79348eb9637d 100644 --- a/src/darwin/Framework/CHIP/CHIPError.mm +++ b/src/darwin/Framework/CHIP/CHIPError.mm @@ -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:@{ @@ -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; }