diff --git a/ArchiSteamFarm/Logging.cs b/ArchiSteamFarm/Logging.cs index 1539744a993f7..39ec2d06a0c12 100644 --- a/ArchiSteamFarm/Logging.cs +++ b/ArchiSteamFarm/Logging.cs @@ -69,7 +69,7 @@ internal static void LogGenericException(Exception exception, string botName = " } Log("[!] EXCEPTION: " + previousMethodName + "() <" + botName + "> " + exception.Message); - Log("[!] StackTrace: " + exception.StackTrace); + Log("[!] StackTrace:" + Environment.NewLine + exception.StackTrace); if (exception.InnerException != null) { LogGenericException(exception.InnerException, botName, previousMethodName); diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index 3e048bcce689f..932c060135fab 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -414,8 +414,17 @@ private static void UnhandledExceptionHandler(object sender, UnhandledExceptionE Logging.LogGenericException((Exception) args.ExceptionObject); } + private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) { + if (sender == null || args == null) { + return; + } + + Logging.LogGenericException(args.Exception); + } + private static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; + TaskScheduler.UnobservedTaskException += UnobservedTaskExceptionHandler; Logging.LogGenericInfo("Archi's Steam Farm, version " + Version); Directory.SetCurrentDirectory(ExecutableDirectory);