I'm using cats, wonder how to turn a data with it.
From
val data = Either[Error, Option[Either[Error, Account]]]
to
val target: Either[Error, Option[Account]] = howToConvert(data)
If there is any Error
happens, the result will be Left(error)
with the first appeared error.
I can do it now with:
data match {
case Left(e) => Left(e)
case Right(Some(Right(y))) => Right(Some(y))
case Right(Some(Left(e))) => Left(e)
case Right(None) => Right(None)
}
But I'm looking for some easy way