CSharp · Console
using System;
using System.Threading.Tasks;
public class Program
{
public static void Main()
{
var task = WriteToLogAsync();
Console.WriteLine("The exception goes unnoticed");
Task.Delay(500);
var message = task.Exception.InnerExceptions[0].Message;
Console.WriteLine(message); // This exception is lost.
}
public static async Task WriteToLogAsync()
{
System.Console.WriteLine("Trying to write to the log");
await Task.Yield();
throw new Exception("This exception is lost");
}
}