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
This commit is contained in:
JKlingen 2012-10-21 09:37:13 +00:00
parent a090e3e8d6
commit ea52882bd3
2 changed files with 16 additions and 6 deletions

View file

@ -1,15 +1,21 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Threading;
using System.Data; using System.Data;
using System.Xml; using System.Xml;
using System.Configuration; using System.Configuration;
namespace GreenshotLanguageEditor namespace GreenshotLanguageEditor {
{
/// <summary> /// <summary>
/// Interaction logic for App.xaml /// Interaction logic for App.xaml
/// </summary> /// </summary>
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;
}
} }
} }

View file

@ -15,6 +15,7 @@ using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using Greenshot.Helpers;
namespace GreenshotLanguageEditor namespace GreenshotLanguageEditor
{ {
@ -23,11 +24,14 @@ namespace GreenshotLanguageEditor
/// </summary> /// </summary>
public partial class ErrorWindow : Window public partial class ErrorWindow : Window
{ {
public ErrorWindow(string msg) public ErrorWindow(Exception e)
{ {
InitializeComponent(); InitializeComponent();
this.Title = "Unexpected Error in GreenshotLanguageEditor";
this.textBox.Text = msg; this.textBox.Text = "Sorry, an unexpected error occurred :(\n\n"
+ EnvironmentInfo.BuildReport(e);
} }
} }
} }