All Downloads are FREE. Search and download functionalities are using the official Maven repository.

validation.Transformation.scala Maven / Gradle / Ivy

The newest version!
package ltbs.uniform
package validation

import cats.NotNull
import cats.data.Validated
import scala.reflect.ClassTag

object Transformation {
  final class CatchOnlyPartiallyApplied[T >: Null <: Throwable](val errorMsg: String) extends AnyVal {
    def apply[A,B](f: A => B)(implicit CT: ClassTag[T], NT: NotNull[T]): Transformation[A, B] = {a: A => 
      Validated.catchOnly[T](f(a))
        .leftMap(_ => ErrorMsg(errorMsg).toTree)
    }
  }

  def catchOnly[T >: Null <: Throwable](errorMsg: String): CatchOnlyPartiallyApplied[T] =
    new CatchOnlyPartiallyApplied[T](errorMsg: String)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy