mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Log also unhandled exceptions
This commit is contained in:
@@ -62,6 +62,12 @@ namespace ArchiSteamFarm {
|
||||
|
||||
internal static void LogGenericException(string botName, Exception exception, [CallerMemberName] string previousMethodName = "") {
|
||||
Log("[!] EXCEPTION: " + previousMethodName + "() <" + botName + "> " + exception.Message);
|
||||
Log("[!] StackTrace: " + exception.StackTrace);
|
||||
|
||||
Exception innerException = exception.InnerException;
|
||||
if (innerException != null) {
|
||||
LogGenericException(botName, innerException, previousMethodName);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LogGenericWarning(string botName, string message, [CallerMemberName] string previousMethodName = "") {
|
||||
|
||||
@@ -204,7 +204,17 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) {
|
||||
if (sender == null || args == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.LogGenericException("Main", (Exception) args.ExceptionObject);
|
||||
}
|
||||
|
||||
private static void Main(string[] args) {
|
||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionHandler);
|
||||
|
||||
Logging.LogGenericInfo("Main", "Archi's Steam Farm, version " + Version);
|
||||
Directory.SetCurrentDirectory(ExecutableDirectory);
|
||||
InitServices();
|
||||
|
||||
Reference in New Issue
Block a user