What\'s the cleanest way to map the Exception of a failed Future in scala?
Say I have:
import scala.concurrent         
        There is also:
f recover { case cause => throw new Exception("Something went wrong", cause) }
Since Scala 2.12 you can do:
f transform {
  case s @ Success(_) => s
  case Failure(cause) => Failure(new Exception("Something went wrong", cause))
}
or
f transform { _.transform(Success(_), cause => Failure(new Exception("Something went wrong", cause)))}
You could try recoverWith as in:
f recoverWith{
  case ex:Exception => Future.failed(new Exception("foo", ex))
}