Added application-level unhandled exception handler

This commit is contained in:
Ben 2015-07-02 22:02:51 +01:00
parent 45b9d87ddb
commit bf4781dbde
2 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,8 @@
using System.IO.Compression;
using System;
using System.IO.Compression;
using System.Linq;
using System.Windows;
using System.Windows.Threading;
using AutoMapper;
using Castle.Facilities.TypedFactory;
using Castle.MicroKernel.ModelBuilder.Inspectors;
@ -57,14 +59,23 @@ namespace Filtration
Mapper.CreateMap<IThemeViewModel, Theme>();
Mapper.AssertConfigurationIsValid();
DispatcherUnhandledException += OnDispatcherUnhandledException;
var mainWindow = _container.Resolve<IMainWindow>();
mainWindow.Show();
}
public void TestTest()
public void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
var exception = e.Exception.Message + Environment.NewLine + e.Exception.StackTrace;
var innerException = e.Exception.InnerException != null
? e.Exception.InnerException.Message + Environment.NewLine +
e.Exception.InnerException.StackTrace
: string.Empty;
MessageBox.Show(
exception + Environment.NewLine + innerException,
"Unhandled Exception", MessageBoxButton.OK, MessageBoxImage.Error);
}
protected override void OnExit(ExitEventArgs e)

View File

@ -139,6 +139,7 @@ namespace Filtration.ViewModels
}
});
CheckForUpdates();
throw new Exception("Test of dispatcher exception handler");
}
public RelayCommand OpenScriptCommand { get; private set; }