Skip to content

Commit

Permalink
Add UnobservedTaskExceptionHandler, thank you @Netshroud
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Mar 14, 2016
1 parent 4181f3b commit 0bb2b3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ArchiSteamFarm/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions ArchiSteamFarm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0bb2b3e

Please sign in to comment.