Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.13+1

* Handle translation of errors nested in dictionaries.

## 0.3.13

* Added new native tests for more complete test coverage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,11 @@ + (NSDictionary *)getMapFromNSError:(NSError *)error {
return nil;
}

NSMutableDictionary *userInfo = [NSMutableDictionary new];
for (NSErrorUserInfoKey key in error.userInfo) {
id value = error.userInfo[key];
userInfo[key] = [FIAObjectTranslator encodeNSErrorUserInfo:value];
}
return @{@"code" : @(error.code), @"domain" : error.domain ?: @"", @"userInfo" : userInfo};
return @{
@"code" : @(error.code),
@"domain" : error.domain ?: @"",
@"userInfo" : [FIAObjectTranslator encodeNSErrorUserInfo:error.userInfo]
};
}

+ (id)encodeNSErrorUserInfo:(id)value {
Expand All @@ -189,6 +188,12 @@ + (id)encodeNSErrorUserInfo:(id)value {
[errors addObject:[FIAObjectTranslator encodeNSErrorUserInfo:error]];
}
return errors;
} else if ([value isKindOfClass:[NSDictionary class]]) {
NSMutableDictionary *errors = [[NSMutableDictionary alloc] init];
for (id key in value) {
errors[key] = [FIAObjectTranslator encodeNSErrorUserInfo:value[key]];
}
return errors;
} else {
return [NSString
stringWithFormat:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,26 @@ - (void)testErrorWithMultipleUnderlyingErrors {
XCTAssertEqualObjects(expectedMap, map);
}

- (void)testErrorWithNestedUnderlyingError {
NSError *underlyingError = [NSError errorWithDomain:SKErrorDomain code:2 userInfo:nil];
NSError *mainError =
[NSError errorWithDomain:SKErrorDomain
code:3
userInfo:@{@"nesting" : @{@"underlyingError" : underlyingError}}];
NSDictionary *expectedMap = @{
@"domain" : SKErrorDomain,
@"code" : @3,
@"userInfo" : @{
@"nesting" : @{
@"underlyingError" : @{@"domain" : SKErrorDomain, @"code" : @2, @"userInfo" : @{}},

}
}
};
NSDictionary *map = [FIAObjectTranslator getMapFromNSError:mainError];
XCTAssertEqualObjects(expectedMap, map);
}

- (void)testErrorWithUnsupportedUserInfo {
NSError *error = [NSError errorWithDomain:SKErrorDomain
code:3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: in_app_purchase_storekit
description: An implementation for the iOS and macOS platforms of the Flutter `in_app_purchase` plugin. This uses the StoreKit Framework.
repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_storekit
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 0.3.13
version: 0.3.13+1

environment:
sdk: ^3.2.3
Expand Down