Quantcast
Channel: Fail a Future from a mapping method - Stack Overflow
Browsing all 2 articles
Browse latest View live

Answer by SergGr for Fail a Future from a mapping method

You may use flatMap instead such as:xOptionFuture.flatMap { case Some(x) => Future.successful(x) case None => Future.failed(new IllegalArgumentException("Option is None"))}

View Article



Fail a Future from a mapping method

I have a Future[Option[X]] and would like to "unbox" the inner Option in a way that the outer Future fails if the Option is empty, and directly provides the value otherwise. In other words, I'd like to...

View Article
Browsing all 2 articles
Browse latest View live




Latest Images