dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.22k stars 5.87k forks source link

Is the recomendation about catching AgregateException actual? #25855

Open RomanGirin opened 3 years ago

RomanGirin commented 3 years ago

As a feedback: I recently worked through the similar code and find out that instead of AggregateException Exception is thrown. I googled it and found out the similar question on Stackoverflow. https://stackoverflow.com/questions/12007781/why-doesnt-await-on-task-whenall-throw-an-aggregateexception

Quote from the link above "When you use await, the code generated by the compiler unwraps the AggregateException and throws the underlying exception.". This correlates with my personal debug results in similar code.

Please check if some updates to the content are required.

[Enter feedback here]


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

RomanGirin commented 3 years ago

Also noticed that in the article Task is NOT awaited. When Task DO awaited the exception is unwraped. I guess this is the reason of differences, but it would be great to check and add few remarks about it in the content as it create a huge deal of confusion

BillWagner commented 3 years ago

Thanks for noting this @RomanGirin

I've added this to our project to update our task based articles. We plan on working in this area toward the end of this year, and early in the next year, after the .NET 6 release.