Example #1
0
        public static async Task <HttpResponseMessage> RequestCouchDb(this CouchApi self, HttpRequestMessage request)
        {
            try
            {
                return(await self.SendAsync(request));
            }
            catch (Exception e)
            {
                var aggregateException = e as AggregateException;
                if (aggregateException != null)
                {
                    var innerExceptions = aggregateException.InnerExceptions;

                    var newInnerExceptions = new Exception[innerExceptions.Count];
                    for (var i = 0; i < innerExceptions.Count; i++)
                    {
                        newInnerExceptions[i] = WrapIfNeeded(innerExceptions[i]);
                    }
                    throw new AggregateException(aggregateException.Message, newInnerExceptions);
                }

                throw WrapIfNeeded(e);
            }
        }