title: HttpClient - dealing with aggregate exceptions
body: <p>Hi i am using HttpClient similar to this:</p>
  
  <pre><code>public static Task&lt;string&gt; AsyncStringRequest(string url, string contentType)
  {
      try
      {
          var client = new HttpClient();
          client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(contentType));
  
          return client.GetStringAsync(url).ContinueWith(task =&gt; {
              return task.Result;
          });
      }
      catch (AggregateException ex)
      {
          throw ex;
      }
      catch (WebException ex)
      {
          throw ex;
      }       
      catch (Exception ex)
      {
          throw ex;
      }
  }
  </code></pre>
  
  <p>But i am having difficulties dealing with exceptions. I have added the additional catch blocks just to try and step throw, but none of the break points are caught in any of the catch blocks. I realise using Task the exception could occur on a different thread than the caller so the exception is wrapped in a aggregate container, but i am not sure what the best way to deal with these exceptions is.</p>
  
  <p>For example i make a request to a web service and specific an invalid parameter in the request, and an exception is thrown. I want to me able to catch the aggregate exceptions and look at the innerexceptions to work out why the request has failed and return a friendly message.</p>
  
  <p>So my question is, what is the best way to catch these aggregate exceptions and deal with them?</p>