title: Does scala.concurrent.Future have this functionality out of box?
body: <p>So I often find myself writing this helper function and finally got sick of it and decided to ask about it. The functionality I want is to map a failed Future to another failed Future based on the exception "thrown".</p>
  
  <p>Does Future have this functionality and I just haven't found it yet?</p>
  
  <pre><code>object FutureUtils {
    implicit class FutureWrapper[T](val fut: Future[T]) extends AnyVal {
      def mapFailure(f: PartialFunction[Throwable, Throwable])(implicit ec: ExecutionContext) = {
        val p = Promise[T]()
        fut onComplete {
          case Success(a) ⇒ p success a
          case Failure(e) ⇒ p failure f.applyOrElse(e, (t: Throwable) ⇒ t)
        }
        p.future
      }
    }
  }
  </code></pre>