Feature UnhandledException handled

This commit is contained in:
Somebody
2024-09-14 17:13:56 +08:00
parent 7b5d404906
commit 6681c761e3
4 changed files with 14 additions and 0 deletions

View File

@@ -155,6 +155,8 @@ public class ServerInfoTextCHS
public string UnloadedItems => "卸载了所有 {0}。";
public string SaveDatabase => "已保存数据库,用时 {0}s";
public string WaitForAllDone => "现在还不可以进入游戏,请等待所有项目加载完成后再试";
public string UnhandledException => "发生未经处理的异常:{0}";
}
#endregion

View File

@@ -153,6 +153,8 @@ public class ServerInfoTextCHT
public string UnloadedItems => "卸載了所有 {0}。";
public string SaveDatabase => "已保存數據庫,用時 {0}s";
public string WaitForAllDone => "現在還不可以進入遊戲,請等待所有項目加載完成後再試";
public string UnhandledException => "未處理的異常:{0}";
}
#endregion

View File

@@ -158,6 +158,8 @@ public class ServerInfoTextEN
public string SaveDatabase => "Database saved in {0}s";
public string WaitForAllDone => "You cannot enter the game yet. Please wait for all items to load before trying again";
public string UnhandledException => "An unhandled exception occurred: {0}";
}
#endregion

View File

@@ -32,6 +32,14 @@ public class EntryPoint
Logger.Info(I18NManager.Translate("Server.ServerInfo.Shutdown"));
PerformCleanup();
};
AppDomain.CurrentDomain.UnhandledException += (obj, arg) =>
{
Logger.Error(I18NManager.Translate("Server.ServerInfo.UnhandledException", obj.GetType().Name), (Exception)arg.ExceptionObject);
Logger.Info(I18NManager.Translate("Server.ServerInfo.Shutdown"));
PerformCleanup();
Environment.Exit(1);
};
Console.CancelKeyPress += (_, eventArgs) =>
{
Logger.Info(I18NManager.Translate("Server.ServerInfo.CancelKeyPressed"));