Created
August 25, 2016 13:09
-
-
Save alexanderjamesking/37b8917a84ed5fb337583e45b7676131 to your computer and use it in GitHub Desktop.
Scala FutureExceptions Test Trait - getExceptionFromFuture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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