Predicate in scala for comprehension
Today I made a for comprehension that had a predicate in it.
The problem with predicates in for comprehensions, is that if they fail they give a pretty bad exception : “java.util.NoSuchElementException: Future.filter predicate is not satisfied”
Finding a message like this in a log is not very useful. So I searched stack overflow for a solution, and found it
Now I did change the name of the function to ifNot instead of predicate, as this is more readable to me, so the code I ended up with was something like this: