
io.magentys.donut.package.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of donut Show documentation
Show all versions of donut Show documentation
Magentys Donut - Reporting Tool
The newest version!
package io.magentys
import scala.util.{Failure, Success, Try}
package object donut {
implicit class TryExtension[A](t: Try[A]) {
def toEither[E](f: Throwable => E): Either[E, A] = {
t match {
case Success(s) => Right(s)
case Failure(e) => Left(f(e))
}
}
}
def sequenceEither[E, R](s: List[Either[E, R]]): Either[List[E], List[R]] = {
val errors = s.filter(_.isLeft).map(e => e.left.get)
if (errors.nonEmpty) Left(errors) else Right(s.map(e => e.right.get))
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy