Skip to content

Commit

Permalink
Add global unhandled exception check.
Browse files Browse the repository at this point in the history
  • Loading branch information
qianlifeng committed Mar 11, 2014
1 parent 79d011b commit 8ef6827
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Wox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public partial class MainWindow
public MainWindow()
{
InitializeComponent();

AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

progressBar.ToolTip = toolTip;
InitialTray();
resultCtrl.OnMouseClickItem += AcceptSelect;
Expand All @@ -64,6 +67,19 @@ public MainWindow()
SetCustomPluginHotkey();
}

private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (!System.Diagnostics.Debugger.IsAttached)
{
string error = "Wox has an error that can't be handled. " + e.ExceptionObject;
Log.Error(error);
if (e.IsTerminating)
{
MessageBox.Show(error);
}
}
}

public void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
{
var hotkey = new HotkeyModel(hotkeyStr);
Expand Down

0 comments on commit 8ef6827

Please sign in to comment.