-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
64 lines (56 loc) · 2.02 KB
/
Program.cs
File metadata and controls
64 lines (56 loc) · 2.02 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2026 ubidzz. All Rights Reserved.
//
// This file is part of Synix Control Panel.
//
// This code is provided for transparent viewing and personal use only.
// Unauthorized distribution, public modification, or commercial
// use of this source code or the compiled executable is strictly
// prohibited. Please refer to the LICENSE file in the root
// directory for full terms.
namespace Synix_Control_Panel
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// 🛡️ 1. CATCH UI THREAD CRASHES
// Catches things like bad button clicks or grid rendering errors
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
// 🛡️ 2. CATCH BACKGROUND THREAD CRASHES
// Catches things like Watchdog failures or Engine loop crashes
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainGUI());
}
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
LogFatalCrash(e.Exception);
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject is Exception ex)
{
LogFatalCrash(ex);
}
}
static void LogFatalCrash(Exception ex)
{
try
{
string logFilePath = Path.Combine(@"C:\Synix\SynixData\logs", "Synix_fatal_crashes.log");
FileHandler.WriteLog("Synix_fatal_crashes", $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [FATAL CRASH]\r\n{ex.Message}\r\n{ex.StackTrace}\r\n----------------------------------------\r\n");
MessageBox.Show($"Synix encountered a critical error and needs to close. Please check {logFilePath} for details.",
"Engine Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch
{
// Silent fail
}
}
}
}