0
votes

I am trying to single out the iOS error from the parse error that is generated by:

[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {...

When I print the [error userInfo] I get this result:

Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo=0x7f93c5930960 {NSUnderlyingError=0x7f93c5e7d430 "The Internet connection appears to be offline.", NSErrorFailingURLStringKey=https://api.parse.com/2/find, NSErrorFailingURLKey=https://api.parse.com/2/find, _kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, NSLocalizedDescription=The Internet connection appears to be offline.}

I assume the parse API adds the IOS connection NSError to the parse generated NSError. How can I retrieve the original NSError? More specifically, I want to get the NSString of the last NSLocalizedDescription, ie " The Internet connection appears to be offline."

Thank you for your help.

1

1 Answers

0
votes

The original error is embedded within the userInfo object of the error created by Parse, with the key originalError. Within here, you can get the localizedDescription which is the value you're after.

[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
  if (error) {
    NSError *originalError = error.userInfo[@"originalError"];
    NSString *description = originalError.localizedDescription;
    ...
 }
}];