Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Add better error handling to Facebook provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
calebd committed Sep 30, 2014
1 parent 8c33fd7 commit 3f5fef0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
15 changes: 13 additions & 2 deletions Providers/Facebook/SimpleAuthFacebookProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,22 @@ - (RACSignal *)remoteAccountWithSystemAccount:(ACAccount *)account {
[subscriber sendCompleted];
}
else {
[subscriber sendError:parseError];
NSMutableDictionary *dictionary = [NSMutableDictionary new];
if (parseError) {
dictionary[NSUnderlyingErrorKey] = parseError;
}
NSError *error = [NSError errorWithDomain:SimpleAuthErrorDomain code:SimpleAuthErrorInvalidData userInfo:dictionary];
[subscriber sendNext:error];
}
}
else {
[subscriber sendError:connectionError];
NSMutableDictionary *dictionary = [NSMutableDictionary new];
if (connectionError) {
dictionary[NSUnderlyingErrorKey] = connectionError;
}
dictionary[SimpleAuthErrorStatusCodeKey] = @(statusCode);
NSError *error = [NSError errorWithDomain:SimpleAuthErrorDomain code:SimpleAuthErrorNetwork userInfo:dictionary];
[subscriber sendError:error];
}
}];
return nil;
Expand Down
15 changes: 13 additions & 2 deletions Providers/Twitter/SimpleAuthTwitterProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,22 @@ - (RACSignal *)accountWithAccessToken:(NSDictionary *)accessToken {
[subscriber sendCompleted];
}
else {
[subscriber sendError:parseError];
NSMutableDictionary *dictionary = [NSMutableDictionary new];
if (parseError) {
dictionary[NSUnderlyingErrorKey] = parseError;
}
NSError *error = [NSError errorWithDomain:SimpleAuthErrorDomain code:SimpleAuthErrorInvalidData userInfo:dictionary];
[subscriber sendNext:error];
}
}
else {
[subscriber sendError:connectionError];
NSMutableDictionary *dictionary = [NSMutableDictionary new];
if (connectionError) {
dictionary[NSUnderlyingErrorKey] = connectionError;
}
dictionary[SimpleAuthErrorStatusCodeKey] = @(statusCode);
NSError *error = [NSError errorWithDomain:SimpleAuthErrorDomain code:SimpleAuthErrorNetwork userInfo:dictionary];
[subscriber sendError:error];
}
}];
return nil;
Expand Down

0 comments on commit 3f5fef0

Please sign in to comment.