title: Map the Exception of a failed Future
body: <p>What's the cleanest way to <code>map</code> the <code>Exception</code> of a failed <code>Future</code> in scala?</p>
  
  <p>Say I have:</p>
  
  <pre><code>import scala.concurrent._
  import scala.concurrent.ExecutionContext.Implicits.global
  
  val f = Future { 
    if(math.random &lt; 0.5) 1 else throw new Exception("Oh no") 
  }
  </code></pre>
  
  <p>If the Future succeeds with <code>1</code>, I'd like to keep that, however if it fails I would like to change the <code>Exception</code> to a different <code>Exception</code>.</p>
  
  <p>The best I could come up with is transform, however that requires me to make a needless function for the success case:</p>
  
  <pre><code>val f2 = f.transform(s =&gt; s, cause =&gt; new Exception("Something went wrong", cause))
  </code></pre>
  
  <p>Is there any reason there is no <code>mapFailure(PartialFunction[Throwable,Throwable])</code>?</p>