From ea52882bd3c56b5b03d1da264e92aedc3347f7ea Mon Sep 17 00:00:00 2001 From: JKlingen Date: Sun, 21 Oct 2012 09:37:13 +0000 Subject: [PATCH] language editor: display error message with stacktrace in case of unexpected exception git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2180 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- GreenshotLanguageEditor/App.xaml.cs | 14 ++++++++++---- GreenshotLanguageEditor/ErrorWindow.xaml.cs | 8 ++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/GreenshotLanguageEditor/App.xaml.cs b/GreenshotLanguageEditor/App.xaml.cs index fd4d50b9c..88f1efc19 100644 --- a/GreenshotLanguageEditor/App.xaml.cs +++ b/GreenshotLanguageEditor/App.xaml.cs @@ -1,15 +1,21 @@ using System; using System.Windows; +using System.Windows.Threading; using System.Data; using System.Xml; using System.Configuration; -namespace GreenshotLanguageEditor -{ +namespace GreenshotLanguageEditor { /// /// Interaction logic for App.xaml /// - public partial class App : Application - { + public partial class App : Application { + public App() :base () { + this.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException); + } + void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { + new ErrorWindow(e.Exception).ShowDialog(); + e.Handled = true; + } } } \ No newline at end of file diff --git a/GreenshotLanguageEditor/ErrorWindow.xaml.cs b/GreenshotLanguageEditor/ErrorWindow.xaml.cs index b5ef9a962..9f15b8be5 100644 --- a/GreenshotLanguageEditor/ErrorWindow.xaml.cs +++ b/GreenshotLanguageEditor/ErrorWindow.xaml.cs @@ -15,6 +15,7 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; +using Greenshot.Helpers; namespace GreenshotLanguageEditor { @@ -23,11 +24,14 @@ namespace GreenshotLanguageEditor /// public partial class ErrorWindow : Window { - public ErrorWindow(string msg) + public ErrorWindow(Exception e) { InitializeComponent(); + this.Title = "Unexpected Error in GreenshotLanguageEditor"; - this.textBox.Text = msg; + this.textBox.Text = "Sorry, an unexpected error occurred :(\n\n" + + EnvironmentInfo.BuildReport(e); + } } } \ No newline at end of file