forked from ArduPilot/MissionPlanner
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
47 lines (39 loc) · 1.17 KB
/
Copy pathProgram.cs
File metadata and controls
47 lines (39 loc) · 1.17 KB
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
using System;
using System.IO;
using Avalonia;
using Projektanker.Icons.Avalonia;
using Projektanker.Icons.Avalonia.FontAwesome;
namespace MissionPlanner;
sealed class Program {
[STAThread]
public static void Main(string[] args) {
Services.AppPaths.Initialize();
AppDomain.CurrentDomain.UnhandledException += (_, e) => LogCrash(e.ExceptionObject as Exception);
System.Threading.Tasks.TaskScheduler.UnobservedTaskException += (_, e) => {
LogCrash(e.Exception);
e.SetObserved();
};
IconProvider.Current.Register<FontAwesomeIconProvider>();
try {
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
} catch (Exception ex) {
LogCrash(ex);
throw;
}
}
private static void LogCrash(Exception? ex) {
if (ex == null) {
return;
}
try {
Directory.CreateDirectory(Path.GetDirectoryName(Services.AppPaths.CrashLogPath)!);
File.AppendAllText(Services.AppPaths.CrashLogPath, $"---- crash ----\n{ex}\n\n");
} catch {
}
}
public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace();
}