1
Vote

Async methods throw instead of returning faulted tasks

description

Task-returning async methods should not throw exceptions. They should return faulted tasks. Otherwise, compositions like this:

await Task.WhenAll(file1.DeleteAsync(), file2.DeleteAsync());

Could end up invoking file1.DeleteAsync() and throwing and never have invoked file2.DeleteAsync().

If you look at the all the async APIs in .NET, WinRT, etc., they never throw directly at their caller. This library should follow the same pattern so that code that switches from platform APIs to this library won't break.

comments