I have a Future[T] and I want to map the result, on both success and failure.
Eg, something like
val future = ... // Future[T] val mapped = future.mapAll
Since Scala 2.12 you can use transform to map both cases:
transform
future.transform { case Success(_) => Try("OK") case Failure(_) => Try("KO") }
You also have transformWith if you prefer to use a Future instead of a Try. Check the documentation for details.
transformWith
Future
Try