Better exception handling

This commit is contained in:
Geoffroy BONNEVILLE
2020-05-05 19:26:38 +02:00
parent 2e22a2bd92
commit 1488c3244f

View File

@@ -153,15 +153,29 @@ namespace ModernKeePass
await _mediator.Send(new ReOpenDatabaseQuery()); await _mediator.Send(new ReOpenDatabaseQuery());
#if DEBUG #if DEBUG
_notification.Show("App resumed", "Database reopened (changes were saved)"); _notification.Show("App resumed", "Database reopened (changes were saved)");
#endif
}
catch (DatabaseOpenException)
{
#if DEBUG
_notification.Show("App resumed", "Previous database still open because it couldn't be closed (probable save error)");
#endif #endif
} }
catch (DatabaseClosedException) catch (DatabaseClosedException)
{ {
_navigation.NavigateTo(Constants.Navigation.MainPage);
#if DEBUG #if DEBUG
_notification.Show("App resumed", "Nothing to do, no previous database opened"); _notification.Show("App resumed", "Nothing to do, no previous database opened");
#endif #endif
} }
catch (Exception ex)
{
_hockey.TrackException(ex);
_hockey.Flush();
}
finally
{
_navigation.NavigateTo(Constants.Navigation.MainPage);
}
} }
/// <summary> /// <summary>
@@ -198,9 +212,14 @@ namespace ModernKeePass
await _mediator.Send(new CloseDatabaseCommand()).ConfigureAwait(false); await _mediator.Send(new CloseDatabaseCommand()).ConfigureAwait(false);
} }
} }
catch (Exception exception) catch (SaveException ex)
{ {
_notification.Show(exception.Source, exception.Message); _notification.Show(_resource.GetResourceValue("MessageDialogSaveErrorTitle"), ex.Message);
}
catch (Exception ex)
{
_hockey.TrackException(ex);
_hockey.Flush();
} }
finally finally
{ {