Skip to content

Instantly share code, notes, and snippets.

@alexanderjamesking
Created August 25, 2016 13:09
Show Gist options
  • Save alexanderjamesking/37b8917a84ed5fb337583e45b7676131 to your computer and use it in GitHub Desktop.
Save alexanderjamesking/37b8917a84ed5fb337583e45b7676131 to your computer and use it in GitHub Desktop.
Scala FutureExceptions Test Trait - getExceptionFromFuture
import org.scalatest.Assertions
import org.scalatest.concurrent.ScalaFutures
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
trait FutureExceptions {
self: Assertions with ScalaFutures =>
def getExceptionFromFuture(future: Future[Any]): Throwable = {
future.map(_ => fail()).recover {
case e => e
}.futureValue
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment