Log unhandled exceptions
This commit is contained in:
@@ -12,8 +12,8 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
@@ -31,19 +31,26 @@ namespace OpenRA
|
||||
return;
|
||||
}
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) => LogException((Exception)e.ExceptionObject);
|
||||
|
||||
try
|
||||
{
|
||||
Run(args);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.AddChannel("exception", "exception.log");
|
||||
var rpt = BuildExceptionReport(e).ToString();
|
||||
Log.Write("exception", "{0}", rpt);
|
||||
Console.Error.WriteLine(rpt);
|
||||
LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void LogException(Exception e)
|
||||
{
|
||||
Log.AddChannel("exception", "exception.log");
|
||||
var rpt = BuildExceptionReport(e).ToString();
|
||||
Log.Write("exception", "{0}", rpt);
|
||||
Console.Error.WriteLine(rpt);
|
||||
}
|
||||
|
||||
static StringBuilder BuildExceptionReport(Exception e)
|
||||
{
|
||||
return BuildExceptionReport(e, new StringBuilder(), 0);
|
||||
|
||||
Reference in New Issue
Block a user