Permalink
Browse files

Give a nicer error message for authentication errors

  • Loading branch information...
1 parent 6fe2696 commit a41fb2ae1322b4a9221728b013acb6ca727c98ab @brentdax committed Oct 25, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 ANRequest.m
View
@@ -163,6 +163,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 a41fb2a

Please sign in to comment.