I have a similar question to what is asked here (Multiple or Single Try Catch), however in my case I need to follow this pattern for functional (and not performance reasons)
Essentially I am handling parameter errors in Scalatra, and I need an easy way to catch if any conversions fail without the first failure skipping the rest of the try calls
In other words, I need something that follows a pattern like this
def checkMultiple(a:Seq[Try]):Either[Map[_,Throwable],Map[_,Success]] = {
???
}
I put in a Sequence of try clauses. Should any of them fail, it will return back a map of all of the failed try's , not just the first one (which will have a map of the try that failed, along with its exception), else it will return a map of all of the try's mapped with their success values
Does anyone know if there is a monadic pattern that already does this in essence, or if there is some util library which does this? Else how would you define the above function?
You can accomplish something much like this with plain Scala, though it's a little more work than with Scalaz'
Validation
.Here it is at work: