Add UnobservedTaskExceptionHandler, thank you @Netshroud

This commit is contained in:
JustArchi
2016-03-14 20:51:29 +01:00
parent 4181f3ba21
commit 0bb2b3ed5f
2 changed files with 10 additions and 1 deletions

View File

@@ -69,7 +69,7 @@ namespace ArchiSteamFarm {
}
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);

View File

@@ -414,8 +414,17 @@ namespace ArchiSteamFarm {
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);