Scala futures error handling
val f: Future[Int] = Future { if(math.random < 0.5) 1 else throw new Exception("Oh no") } recover { case ex:Exception => { println(ex.getMessage) -1 } } f map println