从描述中捕获错误消息

时间:2012-11-11 21:48:02

标签: iphone objective-c ios facebook

这是我在离线模式下尝试从Facebook获取某些信息时收到的错误:([错误说明])

Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" 
UserInfo=0x13f76dd0 {com.facebook.sdk:ErrorInnerErrorKey=Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo=0x13f76860 {NSErrorFailingURLStringKey=https://graph.facebook.com/me/?
fields=name,location,gender,birthday,relationship_status&sdk=ios&migration_bundle=fbsdk%3A20121003&format=json&access_token=xxx, NSErrorFailingURLKey=https://graph.facebook.com/me/?
fields=name,location,gender,birthday,relationship_status&sdk=ios&migration_bundle=fbsdk%3A20121003&format=json&access_token=xxx, NSLocalizedDescription=The Internet connection appears to be offline., 
NSUnderlyingError=0x13e86790 "The Internet connection appears to be offline."}, com.facebook.sdk:HTTPStatusCode=200}

我希望得到这个:The Internet connection appears to be offline.

这个也没有得到我想要的东西:

NSString *description = [error localizedDescription];
NSString *message = [error localizedRecoverySuggestion];

此错误为facebook sdk error 5。 ([错误代码] = 5)

你能帮助我吗?

1 个答案:

答案 0 :(得分:0)

尝试

NSError* underlyingError = [[error userInfo] valueForkey:NSUnderlyingErrorKey];
NSString* description = [underlyingError localizedDescription];