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

Commit 3f5fef0

Browse files
committed
Add better error handling to Facebook provider.
1 parent 8c33fd7 commit 3f5fef0

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

Providers/Facebook/SimpleAuthFacebookProvider.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,22 @@ - (RACSignal *)remoteAccountWithSystemAccount:(ACAccount *)account {
8383
[subscriber sendCompleted];
8484
}
8585
else {
86-
[subscriber sendError:parseError];
86+
NSMutableDictionary *dictionary = [NSMutableDictionary new];
87+
if (parseError) {
88+
dictionary[NSUnderlyingErrorKey] = parseError;
89+
}
90+
NSError *error = [NSError errorWithDomain:SimpleAuthErrorDomain code:SimpleAuthErrorInvalidData userInfo:dictionary];
91+
[subscriber sendNext:error];
8792
}
8893
}
8994
else {
90-
[subscriber sendError:connectionError];
95+
NSMutableDictionary *dictionary = [NSMutableDictionary new];
96+
if (connectionError) {
97+
dictionary[NSUnderlyingErrorKey] = connectionError;
98+
}
99+
dictionary[SimpleAuthErrorStatusCodeKey] = @(statusCode);
100+
NSError *error = [NSError errorWithDomain:SimpleAuthErrorDomain code:SimpleAuthErrorNetwork userInfo:dictionary];
101+
[subscriber sendError:error];
91102
}
92103
}];
93104
return nil;

Providers/Twitter/SimpleAuthTwitterProvider.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,22 @@ - (RACSignal *)accountWithAccessToken:(NSDictionary *)accessToken {
357357
[subscriber sendCompleted];
358358
}
359359
else {
360-
[subscriber sendError:parseError];
360+
NSMutableDictionary *dictionary = [NSMutableDictionary new];
361+
if (parseError) {
362+
dictionary[NSUnderlyingErrorKey] = parseError;
363+
}
364+
NSError *error = [NSError errorWithDomain:SimpleAuthErrorDomain code:SimpleAuthErrorInvalidData userInfo:dictionary];
365+
[subscriber sendNext:error];
361366
}
362367
}
363368
else {
364-
[subscriber sendError:connectionError];
369+
NSMutableDictionary *dictionary = [NSMutableDictionary new];
370+
if (connectionError) {
371+
dictionary[NSUnderlyingErrorKey] = connectionError;
372+
}
373+
dictionary[SimpleAuthErrorStatusCodeKey] = @(statusCode);
374+
NSError *error = [NSError errorWithDomain:SimpleAuthErrorDomain code:SimpleAuthErrorNetwork userInfo:dictionary];
375+
[subscriber sendError:error];
365376
}
366377
}];
367378
return nil;

0 commit comments

Comments
 (0)