onCompletereturns a block, so if you specifically want to use onComplete, you need a temporary variable. Alternatively, with Scala 2.12, you can use the transform to do something like this. Note that you always need to return a value:
def fun = {
Future {
println("Inside Future")
throw new Exception("Discomfort in the sea has pulled itself upon me")
5
}.transform {
res =>
Thread.sleep(5000)
println("Inside map")
res
}
}
An alternative for any version of Scala is to simply make both a map and restore with the same body, but that would not be so elegant.