Merge lp:~rockstar/ubuntuone-ios-music/error-handling into lp:ubuntuone-ios-music

Proposed by Paul Hummer
Status: Merged
Approved by: Zachery Bir
Approved revision: 259
Merged at revision: 236
Proposed branch: lp:~rockstar/ubuntuone-ios-music/error-handling
Merge into: lp:ubuntuone-ios-music
Prerequisite: lp:~rockstar/ubuntuone-ios-music/sort-sso
Diff against target: 62 lines (+32/-19)
1 file modified
view_controllers/UOMusicLoginController.m (+32/-19)
To merge this branch: bzr merge lp:~rockstar/ubuntuone-ios-music/error-handling
Reviewer Review Type Date Requested Status
Zachery Bir Approve
Review via email: mp+125261@code.launchpad.net

This proposal supersedes a proposal from 2012-09-19.

Commit message

Add error handling to UbuntuOne SSO

Description of the change

Use the error handling in the new branch for UbuntuOneAuthKit

To post a comment you must log in.
Revision history for this message
Zachery Bir (urbanape) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'view_controllers/UOMusicLoginController.m'
2--- view_controllers/UOMusicLoginController.m 2012-09-19 16:23:20 +0000
3+++ view_controllers/UOMusicLoginController.m 2012-09-19 16:23:21 +0000
4@@ -53,26 +53,39 @@
5 [self.loginViewController.view setUserInteractionEnabled:NO];
6
7 UOAuthManager *authManager = [UOAuthManager sharedAuthManager];
8- [authManager loginWithUsername:username andPassword:password completionBlock:^(){
9- [authManager fetchSubsonicCredentials:^(NSString *username) {
10+ id completionBlock = ^(){
11+ id subsonicCompletionBlock = ^(NSString *username) {
12 [self.delegate loginControllerDidLoginWithUsername:username];
13- }];
14- }];
15-}
16-
17-- (void)handleError:(NSError*)error;
18-{
19- NSString *errorMessage = [error localizedDescription];
20- if ([error code] == 401)
21- errorMessage = NSLocalizedString(@"Incorrect username or password.", nil);
22- else if (errorMessage == nil)
23- errorMessage = NSLocalizedString(@"An error occured trying to sign in, please try again.", @"Login Error Message");
24-
25- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Ubuntu One", nil) message:errorMessage delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
26- [alert show];
27- [self.loginViewController.view setUserInteractionEnabled:YES];
28- UOSSOCredentialsViewController *loginController = (id)[(UINavigationController*)[self loginViewController] topViewController];
29- [loginController reset];
30+ };
31+ id subsonicErrorBlock = ^(NSError *error) {
32+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Ubuntu One", nil) message:[error localizedDescription] delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
33+ [alert show];
34+ [self.loginViewController.view setUserInteractionEnabled:YES];
35+ UOSSOCredentialsViewController *loginController = (id)[(UINavigationController*)[self loginViewController] topViewController];
36+ [loginController reset];
37+ };
38+ [authManager fetchSubsonicCredentials:subsonicCompletionBlock errorBlock:subsonicErrorBlock];
39+ };
40+ id errorBlock = ^(NSError *error) {
41+ NSString *errorMessage = nil;[error localizedDescription];
42+ switch (error.code) {
43+ case 401:
44+ errorMessage = NSLocalizedString(@"Incorrect username or password.", nil);
45+ break;
46+ default:
47+ errorMessage = [error localizedDescription];
48+ if (errorMessage == nil) {
49+ errorMessage = NSLocalizedString(@"An error occured trying to sign in, please try again.", @"Login Error Message");
50+ }
51+ break;
52+ }
53+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Ubuntu One", nil) message:errorMessage delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
54+ [alert show];
55+ [self.loginViewController.view setUserInteractionEnabled:YES];
56+ UOSSOCredentialsViewController *loginController = (id)[(UINavigationController*)[self loginViewController] topViewController];
57+ [loginController reset];
58+ };
59+ [authManager loginWithUsername:username andPassword:password completionBlock:completionBlock errorBlock:errorBlock];
60 }
61
62 @end

Subscribers

People subscribed via source and target branches