Skip to content

Commit

Permalink
Only use the domain, code, and localized description for all media er…
Browse files Browse the repository at this point in the history
…rors to prevent crashes.
  • Loading branch information
twstokes committed Jan 14, 2022
1 parent 27fac2a commit 917cadf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions WordPress/Classes/Services/MediaService.m
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ - (NSError *)customMediaUploadError:(NSError *)error remote:(id <MediaServiceRem
case NSURLErrorNetworkConnectionLost:
case NSURLErrorNotConnectedToInternet:
// Clear lack of device internet connection, notify the user
customErrorMessage = NSLocalizedString(@"The internet connection appears to be offline.", @"Error message shown when a media upload fails because the user isn't connected to the internet.");
customErrorMessage = NSLocalizedString(@"The Internet connection appears to be offline.", @"Error message shown when a media upload fails because the user isn't connected to the Internet.");
break;
default:
// Default NSURL error messaging, probably server-side, encourage user to try again
Expand All @@ -434,11 +434,15 @@ - (NSError *)customMediaUploadError:(NSError *)error remote:(id <MediaServiceRem
}
}
}

NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
if (customErrorMessage) {
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
userInfo[NSLocalizedDescriptionKey] = customErrorMessage;
error = [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:userInfo];
} else {
userInfo[NSLocalizedDescriptionKey] = error.localizedDescription;
}

error = [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:userInfo];
return error;
}

Expand Down

0 comments on commit 917cadf

Please sign in to comment.