-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
56 lines (45 loc) · 1.73 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System.Diagnostics;
namespace TacticalBaconLinker
{
internal static class Program
{
public static FormsManager formsManager = new FormsManager();
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.ThreadException += new ThreadExceptionEventHandler(LogErrors);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(LogErrors);
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(formsManager.activeForm);
}
private static void LogErrors(object sender, EventArgs e)
{
Exception exception = new Exception("unbekannter Fehler");
if (e != null)
{
if (e is ThreadExceptionEventArgs tArgs)
exception = tArgs.Exception;
else if (e is UnhandledExceptionEventArgs uArgs)
exception = (Exception)uArgs.ExceptionObject;
}
string strException = GetException(exception);
if (Debugger.IsAttached)
throw exception;
Utils.logError(strException);
}
private static string GetException(Exception ex)
{
if (ex == null)
return "";
string stException = ex.ToString();
if (ex.InnerException != null)
stException += Environment.NewLine + GetException(ex.InnerException);
return stException;
}
}
}