Core - Ensure application data folder exists

UI - Properly catch exceptions during exception display
UI - Display fatal exceptions during Core creation, even before Core initialisation
This commit is contained in:
Robert committed 2020-03-12 10:00:53 +01:00
1 parent 10eaf82ed0
commit 6cf40fa008
4 files changed
+45 -24

No files matched your search

+26 -14
View File
@@ -38,7 +38,15 @@ namespace Artemis.UI
var viewManager = Kernel.Get<IViewManager>();
// Create the Artemis core
_core = Kernel.Get<ICoreService>();
try
{
_core = Kernel.Get<ICoreService>();
}
catch (Exception e)
{
HandleFatalException(e, logger);
throw;
}
// Create and bind the root view, this is a tray icon so don't show it with the window manager
Execute.OnUIThread(() => viewManager.CreateAndBindViewForModelIfNecessary(RootViewModel));
@@ -58,19 +66,7 @@ namespace Artemis.UI
}
catch (Exception e)
{
logger.Fatal(e, "Fatal exception during initialization, shutting down.");
// Can't use a pretty exception dialog here since the UI might not even be visible
Execute.OnUIThread(() =>
{
Kernel.Get<IWindowManager>().ShowMessageBox(e.Message + "\n\n Please refer the log file for more details.",
"Fatal exception during initialization",
MessageBoxButton.OK,
MessageBoxImage.Error
);
Environment.Exit(1);
});
HandleFatalException(e, logger);
throw;
}
});
@@ -106,6 +102,22 @@ namespace Artemis.UI
e.Handled = true;
}
private void HandleFatalException(Exception e, ILogger logger)
{
logger.Fatal(e, "Fatal exception during initialization, shutting down.");
// Can't use a pretty exception dialog here since the UI might not even be visible
Execute.OnUIThread(() =>
{
Kernel.Get<IWindowManager>().ShowMessageBox(e.Message + "\n\n Please refer the log file for more details.",
"Fatal exception during initialization",
MessageBoxButton.OK,
MessageBoxImage.Error
);
Environment.Exit(1);
});
}
private void ShowMainWindow(IWindowManager windowManager, SplashViewModel splashViewModel)
{
Execute.OnUIThread(() =>