本篇主要讨论一下InnerException的处理方法flatten。
async static Task<string> GetInfoAsync(string name, int seconds)
{
await Task.Delay(TimeSpan.FromSeconds(seconds));
throw new Exception(string.Format("Boom from {0}!", name));
}
async static Task AsynchronousProcessing()
{
Console.WriteLine("1. Single exception");
try
{
string result = await GetInfoAsync("Task 1", 2);
Console.WriteLine(result);
}
catch (Exception ex)
{
Console.WriteLine("Exception details: {0}", ex);
}
}
因篇幅问题不能全部显示,请点此查看更多更全内容