News for hackers. Stuff that matters.
Re:Akka Futures In Scala With A Simple Example by arturaz on Monday January 14, 2013 @03:46AM (#5053852)
How about onFailure?
Re:Akka Futures In Scala With A Simple Example by noelwelsh on Monday January 14, 2013 @04:31AM (#5053936)
Let me expand: there is nothing in the type system that will make you handle exceptions in Futures, in the way that Option or Either make you handle the failure case. It is easy for a Future to fail and you to never see a stack trace. E.g. this will silently fail:

  Future { 1 / 0 }
An alternative is to encode the possibility of failure in the type system by using Future[Validation[E,A]] (replace Validation with Try or Either as the whim takes you). Then the type system will remind you to handle the failure case. See my link above for more (scroll down a bit to see the section on error handling).
Re:Akka Futures In Scala With A Simple Example by mmaltiar on Monday January 14, 2013 @05:20AM (#5054059)
I focussed on a example with a happy flow. In Akka Futures you can handle only error conditions of the following type.

for example we have future onSuccess future onFailure

or we have onComplete, future onComplete { case Success(result) ⇒ doSomethingOnSuccess(result) case Failure(failure) ⇒ doSomethingOnFailure(failure) }

else you can follow what is mentioned by noelwalsh