mirror of
https://github.com/bitwarden/android.git
synced 2024-12-19 07:41:52 +03:00
Handle unexpected error cases on API calls better.
This commit is contained in:
parent
a315f36e09
commit
6068a4bd56
5 changed files with 47 additions and 4 deletions
|
@ -84,6 +84,10 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred);
|
||||||
|
}
|
||||||
}, ToolbarItemOrder.Default, 0);
|
}, ToolbarItemOrder.Default, 0);
|
||||||
|
|
||||||
Title = "Add Folder";
|
Title = "Add Folder";
|
||||||
|
|
|
@ -98,6 +98,10 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred);
|
||||||
|
}
|
||||||
}, ToolbarItemOrder.Default, 0);
|
}, ToolbarItemOrder.Default, 0);
|
||||||
|
|
||||||
Title = "Edit Folder";
|
Title = "Edit Folder";
|
||||||
|
@ -143,6 +147,14 @@ namespace Bit.App.Pages
|
||||||
await Navigation.PopModalAsync();
|
await Navigation.PopModalAsync();
|
||||||
_userDialogs.Toast("Folder deleted.");
|
_userDialogs.Toast("Folder deleted.");
|
||||||
}
|
}
|
||||||
|
else if((await deleteTask).Errors.Count() > 0)
|
||||||
|
{
|
||||||
|
await _userDialogs.AlertAsync((await deleteTask).Errors.First().Message, AppResources.AnErrorHasOccurred);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AlertNoConnection()
|
private void AlertNoConnection()
|
||||||
|
|
|
@ -144,6 +144,10 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred);
|
||||||
|
}
|
||||||
}, ToolbarItemOrder.Default, 0);
|
}, ToolbarItemOrder.Default, 0);
|
||||||
|
|
||||||
Title = AppResources.AddSite;
|
Title = AppResources.AddSite;
|
||||||
|
|
|
@ -179,6 +179,10 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
await _userDialogs.AlertAsync(saveTask.Result.Errors.First().Message, AppResources.AnErrorHasOccurred);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred);
|
||||||
|
}
|
||||||
}, ToolbarItemOrder.Default, 0);
|
}, ToolbarItemOrder.Default, 0);
|
||||||
|
|
||||||
Title = "Edit Site";
|
Title = "Edit Site";
|
||||||
|
@ -238,6 +242,14 @@ namespace Bit.App.Pages
|
||||||
await Navigation.PopModalAsync();
|
await Navigation.PopModalAsync();
|
||||||
_userDialogs.Toast("Site deleted.");
|
_userDialogs.Toast("Site deleted.");
|
||||||
}
|
}
|
||||||
|
else if((await deleteTask).Errors.Count() > 0)
|
||||||
|
{
|
||||||
|
await _userDialogs.AlertAsync((await deleteTask).Errors.First().Message, AppResources.AnErrorHasOccurred);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AlertNoConnection()
|
private void AlertNoConnection()
|
||||||
|
|
|
@ -161,13 +161,24 @@ namespace Bit.iOS.Extension
|
||||||
PresentViewController(loadingAlert, true, null);
|
PresentViewController(loadingAlert, true, null);
|
||||||
await saveTask;
|
await saveTask;
|
||||||
|
|
||||||
if(SiteListController != null)
|
if(saveTask.Result.Succeeded)
|
||||||
{
|
{
|
||||||
SiteListController.DismissModal();
|
if(SiteListController != null)
|
||||||
|
{
|
||||||
|
SiteListController.DismissModal();
|
||||||
|
}
|
||||||
|
else if(LoadingController != null)
|
||||||
|
{
|
||||||
|
LoadingController.CompleteUsernamePasswordRequest(UsernameCell.TextField.Text, PasswordCell.TextField.Text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(LoadingController != null)
|
else if(saveTask.Result.Errors.Count() > 0)
|
||||||
{
|
{
|
||||||
LoadingController.CompleteUsernamePasswordRequest(UsernameCell.TextField.Text, PasswordCell.TextField.Text);
|
DisplayAlert(AppResources.AnErrorHasOccurred, saveTask.Result.Errors.First().Message, AppResources.Ok);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue