Packages

trait ErrorControl[F[_], G[_], E] extends Serializable

A type class for principled error handling. ErrorControl is designed to be a supplement to MonadError with more precise typing. It is defined as a relationship between an error-handling type F[A] and a non-error-handling type G[A]. This means a value of F[A] is able to produce either a value of A or an error of type E. Unlike MonadError's handleError method, the controlError function defined in this type class will yield a value that free of any errors, since they've all been handled.

Must adhere to the laws defined in cats.laws.ErrorControlLaws.

Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ErrorControl
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def accept[A](ga: G[A]): F[A]

    Injects this error-free G[A] value into an F[A].

  2. abstract def controlError[A](fa: F[A])(f: (E) ⇒ G[A]): G[A]

    Handle any error and recover from it, by mapping it to an error-free G[A] value.

    Handle any error and recover from it, by mapping it to an error-free G[A] value.

    Similar to handleErrorWith on ApplicativeError

    Example:

    scala> import cats._, data._, implicits._
    
    scala> EitherT(List(42.asRight, "Error!".asLeft, 7.asRight)).controlError(err => List(0, -1))
    res0: List[Int] = List(42, 0, -1, 7)
  3. abstract def monadErrorF: MonadError[F, E]

    The MonadError instance for F[_]

  4. abstract def monadG: Monad[G]

    The Monad instance for G[_]

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def absolve[A](gea: G[Either[E, A]]): F[A]

    The inverse of trial.

    The inverse of trial.

    Example:

    scala> import cats._, data._, implicits._
    
    scala> List(42.asRight, "Error!".asLeft, 7.asRight).absolve[EitherT[List, String, ?]]
    res0: EitherT[List, String, Int] = EitherT(List(Right(42), Left(Error!), Right(7)))
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def assure[A](ga: G[A])(error: (A) ⇒ Option[E]): F[A]

    Turns a successful value into an error specified by the error function if it does not satisfy a given predicate.

    Turns a successful value into an error specified by the error function if it does not satisfy a given predicate.

    Example:

    scala> import cats._, data._, implicits._
    
    scala> List(42, 23, -4).assure[EitherT[List, String, ?]](n => if (n < 0) Some("Negative number: " + n) else None)
    res0: EitherT[List, String, Int] = EitherT(List(Right(42), Right(23), Left(Negative number: -4)))
  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  8. def control[A, B](fa: F[A])(f: (Either[E, A]) ⇒ G[B]): G[B]

    Transform this F[A] value, by mapping either the error or the valid value to a new error-free G[B].

  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. def intercept[A](fa: F[A])(f: (E) ⇒ A): G[A]

    Handle any error and recover from it, by mapping it to A.

    Handle any error and recover from it, by mapping it to A.

    Similar to handleError on ApplicativeError

    Example:

    scala> import cats._, data._, implicits._
    
    scala> EitherT(List(42.asRight, "Error!".asLeft, 7.asRight, "Another error".asLeft)).intercept(_ => 0)
    res0: List[Int] = List(42, 0, 7, 0)
  15. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. def trial[A](fa: F[A]): G[Either[E, A]]

    Handle errors by turning them into scala.util.Either values inside G.

    Handle errors by turning them into scala.util.Either values inside G.

    If there is no error, then an scala.util.Right value will be returned.

    All non-fatal errors should be handled by this method.

    Similar to attempt on ApplicativeError.

  22. def trialT[A](fa: F[A]): EitherT[G, E, A]

    Like trial, but returns inside the cats.data.EitherT monad transformer instead.

  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped