Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Commit

Permalink
Better errors for sign in and sign up. Fixes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
soffes committed Oct 1, 2012
1 parent f170c4d commit bb879ab
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Classes/CDISignInViewController.m
Expand Up @@ -150,8 +150,13 @@ - (void)signIn:(id)sender {
[self.navigationController dismissModalViewControllerAnimated:YES];
});
} failure:^(AFJSONRequestOperation *operation, NSError *error) {
NSString *message = [[operation responseJSON] objectForKey:@"error_description"];

dispatch_async(dispatch_get_main_queue(), ^{
[hud failAndDismissWithTitle:[[operation response] statusCode] == 401 ? @"Invalid" : @"Failed"];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
});
}];
}
Expand All @@ -171,8 +176,13 @@ - (void)signUp:(id)sender {
[self.navigationController dismissModalViewControllerAnimated:YES];
});
} failure:^(AFJSONRequestOperation *operation, NSError *error) {
NSString *message = [[operation responseJSON] objectForKey:@"error_description"];

dispatch_async(dispatch_get_main_queue(), ^{
[hud failAndDismissWithTitle:@"Failed"];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
});
}];
}
Expand Down

0 comments on commit bb879ab

Please sign in to comment.