title: Preserve exception when continuing Task<T>
body: <p>I've got a Task&lt;T&gt;:</p>
  
  <pre><code>Task&lt;A&gt; someTask = ...
  </code></pre>
  
  <p>This task can result in being successful, faulted or cancelled.</p>
  
  <p>I want to transform the result when the task is successful, and preserve the outcome if not.</p>
  
  <p>This seems to be really difficult when <code>someTask</code> throws an exception.</p>
  
  <p>What I've tried:</p>
  
  <pre><code>Task&lt;B&gt; resultTask = StartMyTask().ContinueWith&lt;B&gt;(
      t =&gt; Foo(t.Result),
      TaskContinuationOptions.OnlyOnRanToCompletion);
  </code></pre>
  
  <p>This results in <code>resultTask</code> being cancelled if <code>someTask</code> faults. I want it to fault.</p>
  
  <pre><code>Task&lt;B&gt; resultTask = StartMyTask().ContinueWith&lt;B&gt;(
      t =&gt; Foo(t.Result));
  </code></pre>
  
  <p>This breaks into the Visual Studio debugger because <code>.Result</code> throws an exception. If I press F5, <code>resultTask</code> faults as expected, but it smells.</p>
  
  <p>Is there any way to let <code>resultTask</code> to have the same outcome as <code>someTask</code> if <code>someTask</code> faults?</p>
  
  <hr>
  
  <p>Essentially what I'm trying to do is to express something like this with tasks:</p>
  
  <pre><code>int F()
  {
      throw new SomeException();
  }
  
  string G(int x)
  {
      return x.ToString();
  }
  
  try
  {
      string result = G(F());
  }
  catch (SomeException e)
  {
      ...
  }
  </code></pre>