Skip to content

Commit

Permalink
fix: return correct error codes in TuyaRNUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
bb441db committed Jun 5, 2024
1 parent 3aafd23 commit 0505a12
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ios/RNTuyaSdk/Utils/TuyaRNUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ @implementation TuyaRNUtils
+ (void)rejecterWithError:(NSError *)error
handler:(RCTPromiseRejectBlock)rejecter {
if (rejecter) {
rejecter([NSString stringWithFormat:@"%ld", error.code], error.userInfo[NSLocalizedDescriptionKey], error);
NSString* code = [NSString stringWithFormat:@"%ld", error.code];
// Tuya SDK puts error codes in "localizedFailureReason", equivalent to the first argument in the error callback in the Android SDK
if (error.localizedFailureReason) {
code = error.localizedFailureReason;
}
rejecter(code, error.userInfo[NSLocalizedDescriptionKey], error);
}
}

Expand Down

0 comments on commit 0505a12

Please sign in to comment.