Permalink
Browse files

better error checking for when data is not parsed

  • Loading branch information...
1 parent 14ee6ca commit ce44fd89cd4fa4fa00a2e457c79aa686dcbdf8fb @zagraves zagraves committed Dec 16, 2009
Showing with 12 additions and 2 deletions.
  1. +6 −1 Source/YOSSocial/YOSAccessToken.m
  2. +6 −1 Source/YOSSocial/YOSRequestToken.m
View
7 Source/YOSSocial/YOSAccessToken.m
@@ -26,7 +26,12 @@ @implementation YOSAccessToken
+ (YOSAccessToken *)tokenFromResponse:(NSData *)responseData
{
- NSDictionary *tokenDictionary = [responseData OAuthTokenResponse];
+ NSDictionary *tokenDictionary = nil;
+ @try {
+ tokenDictionary = [responseData OAuthTokenResponse];
+ } @catch (id responseException) {
+ return nil;
+ }
NSInteger tokenExpires = [[tokenDictionary valueForKey:@"oauth_expires_in"] intValue];
NSInteger authExpires = [[tokenDictionary valueForKey:@"oauth_authorization_expires_in"] intValue];
View
7 Source/YOSSocial/YOSRequestToken.m
@@ -23,7 +23,12 @@ @implementation YOSRequestToken
+ (YOSRequestToken *)tokenFromResponse:(NSData *)responseData
{
- NSDictionary *tokenDictionary = [responseData OAuthTokenResponse];
+ NSDictionary *tokenDictionary = nil;
+ @try {
+ tokenDictionary = [responseData OAuthTokenResponse];
+ } @catch (id responseException) {
+ return nil;
+ }
BOOL isCallbackConfirmed = [[tokenDictionary valueForKey:@"oauth_callback_confirmed"] isEqualToString:@"true"];
NSInteger tokenExpires = [[tokenDictionary valueForKey:@"oauth_expires_in"] intValue];

0 comments on commit ce44fd8

Please sign in to comment.