From 1488c3244f36ad7fe2b037bdb9102e856d02b889 Mon Sep 17 00:00:00 2001 From: Geoffroy BONNEVILLE Date: Tue, 5 May 2020 19:26:38 +0200 Subject: [PATCH] Better exception handling --- ModernKeePass/App.xaml.cs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/ModernKeePass/App.xaml.cs b/ModernKeePass/App.xaml.cs index 80d9758..0f1a105 100644 --- a/ModernKeePass/App.xaml.cs +++ b/ModernKeePass/App.xaml.cs @@ -153,15 +153,29 @@ namespace ModernKeePass await _mediator.Send(new ReOpenDatabaseQuery()); #if DEBUG _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 } catch (DatabaseClosedException) { - _navigation.NavigateTo(Constants.Navigation.MainPage); #if DEBUG _notification.Show("App resumed", "Nothing to do, no previous database opened"); #endif } + catch (Exception ex) + { + _hockey.TrackException(ex); + _hockey.Flush(); + } + finally + { + _navigation.NavigateTo(Constants.Navigation.MainPage); + } } /// @@ -198,9 +212,14 @@ namespace ModernKeePass 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 {