Quantcast
Channel: Fail a Future from a mapping method - Stack Overflow
Browsing latest articles
Browse All 2 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 latest articles
Browse All 2 View Live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>