From: sr55 Date: Sun, 18 Nov 2012 14:47:09 +0000 (+0000) Subject: WinGui: Handle FileNotFound Exceptions with a nicer error message. X-Git-Tag: 0.9.9~283 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ac2e5d661c132980f526ba13772798e012ab155;p=handbrake WinGui: Handle FileNotFound Exceptions with a nicer error message. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5069 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/win/CS/HandBrakeWPF/App.xaml.cs b/win/CS/HandBrakeWPF/App.xaml.cs index ec7bda6b0..b674aa7b6 100644 --- a/win/CS/HandBrakeWPF/App.xaml.cs +++ b/win/CS/HandBrakeWPF/App.xaml.cs @@ -33,7 +33,7 @@ namespace HandBrakeWPF { Application.Current.Dispatcher.UnhandledException += this.Dispatcher_UnhandledException; AppDomain.CurrentDomain.UnhandledException += - new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); + this.CurrentDomain_UnhandledException; } /// @@ -66,7 +66,15 @@ namespace HandBrakeWPF /// private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { - this.ShowError(e.ExceptionObject); + if (e.ExceptionObject.GetType() == typeof(FileNotFoundException)) + { + GeneralApplicationException exception = new GeneralApplicationException("A file appears to be missing.", "Try re-installing Microsoft .NET Framework 4.0", (Exception)e.ExceptionObject); + this.ShowError(exception); + } + else + { + this.ShowError(e.ExceptionObject); + } } /// @@ -81,7 +89,12 @@ namespace HandBrakeWPF private void Dispatcher_UnhandledException( object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { - if (e.Exception.GetType() == typeof(GeneralApplicationException)) + if (e.Exception.GetType() == typeof(FileNotFoundException)) + { + GeneralApplicationException exception = new GeneralApplicationException("A file appears to be missing.", "Try re-installing Microsoft .NET Framework 4.0", e.Exception); + this.ShowError(exception); + } + else if (e.Exception.GetType() == typeof(GeneralApplicationException)) { this.ShowError(e.Exception); }