Permalink
Browse files

Give a nicer error message for authentication errors

  • Loading branch information...
brentdax committed Oct 25, 2012
1 parent 5a0d548 commit 78b433661766f56aee0a582503a0855484d64033
Showing with 8 additions and 0 deletions.
  1. +8 −0 ANRequest.m
View
@@ -160,6 +160,14 @@ - (void)sendRequestWithDataCompletion:(void (^)(NSData * body, NSError * error))
}
}
+ if(error.code == NSURLErrorUserCancelledAuthentication && [error.domain isEqualToString:NSURLErrorDomain]) {
+ NSMutableDictionary * userInfo = error.userInfo.mutableCopy;
+ [userInfo setObject:NSLocalizedString(@"Your account is not allowed to perform this operation.", @"") forKey:NSLocalizedDescriptionKey];
+ [userInfo setObject:error forKey:NSUnderlyingErrorKey];
+
+ error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo.copy];
+ }
+
if(error) {
completion(body, error);
return;

0 comments on commit 78b4336

Please sign in to comment.