-
-
Save anton-putau/416cb5b03649f38edc5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
namespace TestException | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var p = new Program(); | |
p.AsyncMain().Wait(); | |
Console.ReadKey(); | |
} | |
public async Task Run() | |
{ | |
try | |
{ | |
await SomeJob2(); | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine($"{e.GetType()}"); | |
} | |
} | |
public async Task SomeJob() | |
{ | |
throw new Exception(); | |
} | |
public Task SomeJob2() | |
{ | |
try | |
{ | |
return SomeJob(); | |
} | |
catch (Exception e) | |
{ | |
throw new AggregateException(e); | |
} | |
} | |
public async Task AsyncMain() | |
{ | |
await Run(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So, output will be 'exception'. If we wait for async task in SomeJob2 it will be 'aggregateexception'