log unhandle exception

This commit is contained in:
Gang Zhuo
2016-03-04 21:45:23 +08:00
parent 8d863f1d5f
commit 579039fe40
2 changed files with 12 additions and 4 deletions
+2
View File
@@ -101,3 +101,5 @@ Failed to decode QRCode=无法解析二维码
Failed to update registry=无法修改注册表 Failed to update registry=无法修改注册表
System Proxy On: =系统代理已启用: System Proxy On: =系统代理已启用:
Running: Port {0}=正在运行:端口 {0} Running: Port {0}=正在运行:端口 {0}
Unexpect error, shadowsocks will be exit. Please report to=非预期错误,Shadowsocks将退出。请提交此错误到
+10 -4
View File
@@ -55,12 +55,18 @@ namespace Shadowsocks
} }
} }
private static int exited = 0;
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{ {
Logging.Error(e.ExceptionObject?.ToString()); if (Interlocked.Increment(ref exited) == 1)
MessageBox.Show($"Unexpect error, shadowsocks exited.{Environment.NewLine} {e.ExceptionObject?.ToString()}", {
"Shadowsocks", MessageBoxButtons.OK, MessageBoxIcon.Error); Logging.Error(e.ExceptionObject?.ToString());
Application.Exit(); MessageBox.Show(I18N.GetString("Unexpect error, shadowsocks will be exit. Please report to") +
" https://github.com/shadowsocks/shadowsocks-windows/issues " +
Environment.NewLine + (e.ExceptionObject?.ToString()),
"Shadowsocks Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
} }
} }
} }