Re: Are Errors in a Future body rethrown, as per the documentation?
Viktor Klang <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <CANPzfU8J9-MX0GmqS=gU4-JmniFt+m768g-qb3e-SRhgtaWJFA@mail.gmail.com> |
Hi Andrew, I think that behaviour was changed later on. See the revision history / Issues for details. On Mon, Jul 13, 2015 at 10:09 PM, Andrew Phillips <[email protected]> wrote: > Hi all > > With regard to the handling of Errors, the "Futures and Promises" > documentation [1] states: > > ExecutionException - stored when the computation fails due to an >> unhandled InterruptedException, Error or a >> scala.util.control.ControlThrowable. In this case the ExecutionException >> has the unhandled exception as its cause. *These exceptions are rethrown >> in the thread executing the failed asynchronous computation.* > > > Is this latter statement true in general, e.g. also if you supply your own > ExecutionContext? Or does it depend on the ExecutionContext implementation? > > In this example at least, nothing seems to be rethrown (or passed to > reportFailure, for that matter): > > Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java > 1.7.0_40). > > > import scala.concurrent.Future > import scala.concurrent.ExecutionContext > import scala.util.{Failure, Success} > > > implicit object SameThreadExecutionContext extends ExecutionContext { > override def execute(runnable: Runnable): Unit = { > println("DEBUG: running " + runnable) > runnable.run() > } > override def reportFailure(t: Throwable): Unit = ??? // never called? > } > > scala> Future { throw new Error("bang!") }.value > DEBUG: running > scala.concurrent.impl.Future$PromiseCompletingRunnable@887b5d0 > res1: Option[scala.util.Try[Nothing]] = > Some(Failure(java.util.concurrent.ExecutionException: Boxed Error)) > > > Am I missing something or misreading the docs here? > > Regards > > ap > > [1] http://docs.scala-lang.org/overviews/core/futures.html#exceptions > > -- > You received this message because you are subscribed to the Google Groups > "scala-language" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Cheers, √ -- You received this message because you are subscribed to the Google Groups "scala-language" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.