Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

Commit e1754e2

Browse files
committed
Refactoring and error corrections
1 parent b4479f0 commit e1754e2

21 files changed

Lines changed: 54 additions & 49 deletions

CodeHub.Core/ViewModels/Accounts/AccountsViewModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,16 @@ protected async override void SelectAccount(IAccount account)
5252
}
5353
catch (GitHubSharp.UnauthorizedException e)
5454
{
55-
ReportError(e);
55+
DisplayAlert("The credentials for the selected account are incorrect. " + e.Message);
56+
5657
if (isEnterprise)
5758
ShowViewModel<AddAccountViewModel>(new AddAccountViewModel.NavObject { IsEnterprise = true, AttemptedAccountId = githubAccount.Id });
5859
else
5960
ShowViewModel<LoginViewModel>(LoginViewModel.NavObject.CreateDontRemember(githubAccount));
6061
}
6162
catch (Exception e)
6263
{
63-
ReportError(e);
64+
ReportException(e);
6465
}
6566
finally
6667
{

CodeHub.Core/ViewModels/Accounts/AddAccountViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private async Task Login()
111111
if (!(e is LoginService.TwoFactorRequiredException))
112112
{
113113
Password = null;
114-
DisplayException(e);
114+
DisplayAlert(e.Message);
115115
}
116116
}
117117
finally

CodeHub.Core/ViewModels/Accounts/LoginViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public async Task Login(string code)
118118
}
119119
catch (Exception e)
120120
{
121-
ReportError(e);
121+
DisplayAlert(e.Message);
122122
}
123123
finally
124124
{

CodeHub.Core/ViewModels/App/SettingsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private async Task RegisterPushNotifications(bool enabled)
100100
}
101101
catch (Exception e)
102102
{
103-
ReportError(e);
103+
ReportException(e);
104104
}
105105
finally
106106
{

CodeHub.Core/ViewModels/App/StartupViewModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ protected async override void Startup()
6060
}
6161
catch (GitHubSharp.UnauthorizedException e)
6262
{
63-
ReportError(e);
63+
DisplayAlert("The credentials for the selected account are incorrect. " + e.Message);
64+
6465
ShowViewModel<Accounts.AccountsViewModel>();
6566
if (isEnterprise)
6667
ShowViewModel<Accounts.AddAccountViewModel>(new Accounts.AddAccountViewModel.NavObject { IsEnterprise = true, AttemptedAccountId = account.Id });
@@ -69,7 +70,7 @@ protected async override void Startup()
6970
}
7071
catch (Exception e)
7172
{
72-
ReportError(e);
73+
ReportException(e);
7374
ShowViewModel<Accounts.AccountsViewModel>();
7475
}
7576
finally

CodeHub.Core/ViewModels/Gists/GistCreateViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private async Task Save()
8383
{
8484
if (_files.Count == 0)
8585
{
86-
DisplayException(new Exception("You cannot create a Gist without atleast one file"));
86+
DisplayAlert("You cannot create a Gist without atleast one file! Please correct and try again.");
8787
return;
8888
}
8989

@@ -103,7 +103,7 @@ private async Task Save()
103103
}
104104
catch (Exception e)
105105
{
106-
ReportError(e);
106+
DisplayAlert("Unable to create new gist! Please try again.");
107107
}
108108
finally
109109
{

CodeHub.Core/ViewModels/Gists/GistViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private async Task ToggleStarred()
110110
}
111111
catch (Exception e)
112112
{
113-
ReportError(e);
113+
DisplayAlert("Unable to start gist. Please try again.");
114114
}
115115
}
116116

CodeHub.Core/ViewModels/Issues/IssueAddViewModel.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ public class IssueAddViewModel : IssueModifyViewModel
1010
{
1111
protected override async Task Save()
1212
{
13+
if (string.IsNullOrEmpty(Title))
14+
{
15+
DisplayAlert("Unable to save the issue: you must provide a title!");
16+
return;
17+
}
18+
1319
try
1420
{
15-
if (string.IsNullOrEmpty(Title))
16-
throw new Exception("Issue must have a title!");
17-
1821
string assignedTo = AssignedTo == null ? null : AssignedTo.Login;
1922
int? milestone = null;
2023
if (Milestone != null)
@@ -29,7 +32,7 @@ protected override async Task Save()
2932
}
3033
catch (Exception e)
3134
{
32-
ReportError(e);
35+
DisplayAlert("Unable to save new issue! Please try again.");
3336
}
3437
finally
3538
{

CodeHub.Core/ViewModels/Issues/IssueAssignedToViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private async Task SelectUser(BasicUserModel x)
7373
}
7474
catch (Exception e)
7575
{
76-
DisplayException(e);
76+
DisplayAlert("Unable to assign issue to selected user! Please try again.");
7777
}
7878
finally
7979
{

CodeHub.Core/ViewModels/Issues/IssueEditViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected override async Task Save()
7373
}
7474
catch (Exception e)
7575
{
76-
ReportError(e);
76+
DisplayAlert("Unable to save the issue! Please try again");
7777
}
7878
finally
7979
{

0 commit comments

Comments
 (0)