Attempt

sealed abstract
class Attempt[+A] extends Product with Serializable

Right biased Either[Err, A].

An Attempt is either an Attempt.Successful or an Attempt.Failure. Attempts can be created by calling Attempt.successful or Attempt.failure, as well as converting from an Option via fromOption.

Companion
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
class Failure
class Successful[A]

Value members

Abstract methods

def flatMap[B](f: A => Attempt[B]): Attempt[B]

Maps the supplied function over the successful value, if present.

Maps the supplied function over the successful value, if present.

def flatten[B](using A <:< Attempt[B]): Attempt[B]

Converts an Attempt[Attempt[X]] in to an Attempt[X].

Converts an Attempt[Attempt[X]] in to an Attempt[X].

def fold[B](ifFailure: Err => B, ifSuccessful: A => B): B

Transforms this attempt to a value of type B using the supplied functions.

Transforms this attempt to a value of type B using the supplied functions.

def getOrElse[B >: A](default: => B): B

Returns the sucessful value if successful, otherwise the supplied default.

Returns the sucessful value if successful, otherwise the supplied default.

def isSuccessful: Boolean

True if attempt was successful.

True if attempt was successful.

def map[B](f: A => B): Attempt[B]

Maps the supplied function over the successful value, if present.

Maps the supplied function over the successful value, if present.

def mapErr(f: Err => Err): Attempt[A]

Maps the supplied function over the failure error, if present.

Maps the supplied function over the failure error, if present.

def orElse[B >: A](fallback: => Attempt[B]): Attempt[B]

Returns this attempt if successful, otherwise the fallback attempt.

Returns this attempt if successful, otherwise the fallback attempt.

def recover[B >: A](f: PartialFunction[Err, B]): Attempt[B]

If this attempt is a failure, and the supplied partial function is defined for the cause of the failure, a successful attempt is returned. If this attempt is successful or the supplied function is not defined for the cause of the failure, this attempt is returned unmodified.

If this attempt is a failure, and the supplied partial function is defined for the cause of the failure, a successful attempt is returned. If this attempt is successful or the supplied function is not defined for the cause of the failure, this attempt is returned unmodified.

def recoverWith[B >: A](f: PartialFunction[Err, Attempt[B]]): Attempt[B]

If this attempt is a failure, and the supplied partial function is defined for the cause of the failure, the result of applying that function is returned. If this attempt is successful or the supplied function is not defined for the cause of the failure, this attempt is returned unmodified.

If this attempt is a failure, and the supplied partial function is defined for the cause of the failure, the result of applying that function is returned. If this attempt is successful or the supplied function is not defined for the cause of the failure, this attempt is returned unmodified.

def require: A

Returns the successful value if present; otherwise throws an IllegalArgumentException.

Returns the successful value if present; otherwise throws an IllegalArgumentException.

def toEither: Either[Err, A]

Converts to an either.

Converts to an either.

def toOption: Option[A]

Converts to an option, discarding the error value.

Converts to an option, discarding the error value.

def toTry: Try[A]

Converts to a try.

Converts to a try.

Concrete methods

def isFailure: Boolean

True if attempt was not successful.

True if attempt was not successful.

Inherited methods

def canEqual(that: Any): Boolean
Inherited from
Equals
def productArity: Int
Inherited from
Product
def productElement(n: Int): Any
Inherited from
Product
def productElementName(n: Int): String
Inherited from
Product
def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product
def productPrefix: String
Inherited from
Product