Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def zeroOnArithmeticException(x: Future[Int]): Future[Int] = {
- val p = promise[Int]
- x onSuccess {
- case luku => p.trySuccess(luku)
- }
- x onFailure {
- case failure => failure match{
- case e: ArithmeticException => p.tryCompleteWith(future(0))
- case muut => p.tryFailure(muut)
- }
- }
- p.future
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement