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

namespace Firebase.Database.Extensions
{
    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;
            }
        }
    }
}