jenkins-bot has submitted this change and it was merged. Change subject: add API error handling to articlefetcher ......................................................................
add API error handling to articlefetcher See screenshot in referenced phab ticket for an example of what now happens when we encounter an API error in response to a mobileview request. Bug: T102643 Change-Id: I8f434b1e0e4d8d2c7a7647fd7e46a918e008f78a --- M Wikipedia/Networking/Fetchers/ArticleFetcher.m M Wikipedia/Networking/WMFNetworkUtilities.m 2 files changed, 10 insertions(+), 5 deletions(-) Approvals: Fjalapeno: Looks good to me, approved jenkins-bot: Verified diff --git a/Wikipedia/Networking/Fetchers/ArticleFetcher.m b/Wikipedia/Networking/Fetchers/ArticleFetcher.m index 53ba3ca..25b9f65 100644 --- a/Wikipedia/Networking/Fetchers/ArticleFetcher.m +++ b/Wikipedia/Networking/Fetchers/ArticleFetcher.m @@ -81,12 +81,17 @@ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ //NSLog(@"JSON: %@", responseObject); [[MWNetworkActivityIndicatorManager sharedManager] pop]; + // Clear any MCCMNC header - needed because manager is a singleton. + [self removeMCCMNCHeaderFromRequestSerializer:manager.requestSerializer]; // Convert the raw NSData response to a dictionary. NSDictionary* responseDictionary = [self dictionaryFromDataResponse:localResponseObject]; - - // Clear any MCCMNC header - needed because manager is a singleton. - [self removeMCCMNCHeaderFromRequestSerializer:manager.requestSerializer]; + id error = responseDictionary[@"error"]; + if (error) { + NSError* apiError = WMFErrorForApiErrorObject(error); + [self finishWithError:apiError fetchedData:nil]; + return; + } @try { [self.article importMobileViewJSON:responseDictionary[@"mobileview"]]; diff --git a/Wikipedia/Networking/WMFNetworkUtilities.m b/Wikipedia/Networking/WMFNetworkUtilities.m index 366a317..378537e 100644 --- a/Wikipedia/Networking/WMFNetworkUtilities.m +++ b/Wikipedia/Networking/WMFNetworkUtilities.m @@ -24,8 +24,8 @@ void (^ maybeMapApiToUserInfo)(NSString*, NSString*) = ^(NSString* userInfoKey, NSString* apiErrorKey) { [userInfoBuilder wmf_maybeSetObject:apiError[apiErrorKey] forKey:userInfoKey]; }; - maybeMapApiToUserInfo(NSLocalizedDescriptionKey, @"code"); - maybeMapApiToUserInfo(NSLocalizedFailureReasonErrorKey, @"info"); + maybeMapApiToUserInfo(NSLocalizedFailureReasonErrorKey, @"code"); + maybeMapApiToUserInfo(NSLocalizedDescriptionKey, @"info"); maybeMapApiToUserInfo(NSLocalizedRecoverySuggestionErrorKey, @"*"); return [NSError errorWithDomain:WMFNetworkingErrorDomain code:WMFNetworkingError_APIError userInfo:userInfoBuilder]; } -- To view, visit https://gerrit.wikimedia.org/r/226925 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8f434b1e0e4d8d2c7a7647fd7e46a918e008f78a Gerrit-PatchSet: 2 Gerrit-Project: apps/ios/wikipedia Gerrit-Branch: master Gerrit-Owner: Bgerstle <bgers...@wikimedia.org> Gerrit-Reviewer: Fjalapeno <cfl...@wikimedia.org> Gerrit-Reviewer: Mhurd <mh...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits