Skip to content

Commit

Permalink
Give a nicer error message for authentication errors
Browse files Browse the repository at this point in the history
  • Loading branch information
beccadax committed Oct 25, 2012
1 parent 6fe2696 commit a41fb2a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ANRequest.m
Expand Up @@ -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;
Expand Down

0 comments on commit a41fb2a

Please sign in to comment.