mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Implemented error messaging, this resolves #9
This commit is contained in:
parent
81c5b82177
commit
c2c002715c
@ -1,7 +1,9 @@
|
|||||||
<Application x:Class="Artemis.App"
|
<Application x:Class="Artemis.App"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="clr-namespace:Artemis">
|
xmlns:local="clr-namespace:Artemis"
|
||||||
|
DispatcherUnhandledException="Application_DispatcherUnhandledException"
|
||||||
|
Startup="Application_Startup">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
using System.Windows;
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using WpfExceptionViewer;
|
||||||
|
|
||||||
namespace Artemis
|
namespace Artemis
|
||||||
{
|
{
|
||||||
@ -11,5 +14,43 @@ namespace Artemis
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool DoHandle { get; set; }
|
||||||
|
|
||||||
|
private void Application_Startup(object sender, StartupEventArgs e)
|
||||||
|
{
|
||||||
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
if (DoHandle)
|
||||||
|
{
|
||||||
|
GetArtemisExceptionViewer(e.Exception).ShowDialog();
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetArtemisExceptionViewer(e.Exception).ShowDialog();
|
||||||
|
e.Handled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
var ex = e.ExceptionObject as Exception;
|
||||||
|
GetArtemisExceptionViewer(ex).ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ExceptionViewer GetArtemisExceptionViewer(Exception e)
|
||||||
|
{
|
||||||
|
return new ExceptionViewer("An unexpected error occurred in Artemis.", e)
|
||||||
|
{
|
||||||
|
Title = "Artemis - Exception :c",
|
||||||
|
Height = 400,
|
||||||
|
Width = 800
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15,15 +15,7 @@ namespace Artemis
|
|||||||
|
|
||||||
protected override void OnStartup(object sender, StartupEventArgs e)
|
protected override void OnStartup(object sender, StartupEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
DisplayRootViewFor<ShellViewModel>();
|
||||||
{
|
|
||||||
DisplayRootViewFor<ShellViewModel>();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Startup failed :c \n" + ex.InnerException.Message);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user