summaryrefslogtreecommitdiff
path: root/FireBase/Extensions/TaskExtensions.cs
blob: 26bbde6aee8fe3a250ebaeb8957a1aaf8a1c0e9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
namespace Firebase.Database.Extensions
{
    using System;
    using System.Threading.Tasks;

    public static class TaskExtensions
    {
        /// <summary>
        /// Instead of unwrapping <see cref="AggregateException"/> it throws it as it is.
        /// </summary>
        public static async Task WithAggregateException(this Task source)
        {
            try
            {
                await source.ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                throw source.Exception ?? ex;
            }
        }
    }
}