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
.
- Source
- Attempt.scala
- Alphabetic
- By Inheritance
- Attempt
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
canEqual(that: Any): Boolean
- Definition Classes
- Equals
-
abstract
def
flatMap[B](f: (A) ⇒ Attempt[B]): Attempt[B]
Maps the supplied function over the successful value, if present.
-
abstract
def
flatten[B](implicit ev: <:<[A, Attempt[B]]): Attempt[B]
Converts an
Attempt[Attempt[X]]
in to anAttempt[X]
. -
abstract
def
fold[B](ifFailure: (Err) ⇒ B, ifSuccessful: (A) ⇒ B): B
Transforms this attempt to a value of type
B
using the supplied functions. -
abstract
def
getOrElse[B >: A](default: ⇒ B): B
Returns the sucessful value if successful, otherwise the supplied default.
-
abstract
def
isSuccessful: Boolean
True if attempt was successful.
-
abstract
def
map[B](f: (A) ⇒ B): Attempt[B]
Maps the supplied function over the successful value, if present.
-
abstract
def
mapErr(f: (Err) ⇒ Err): Attempt[A]
Maps the supplied function over the failure error, if present.
-
abstract
def
orElse[B >: A](fallback: ⇒ Attempt[B]): Attempt[B]
Returns this attempt if successful, otherwise the fallback attempt.
-
abstract
def
productArity: Int
- Definition Classes
- Product
-
abstract
def
productElement(n: Int): Any
- Definition Classes
- Product
-
abstract
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 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.
-
abstract
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 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.
-
abstract
def
require: A
Returns the successful value if present; otherwise throws an
IllegalArgumentException
. -
abstract
def
toEither: Either[Err, A]
Converts to an either.
-
abstract
def
toOption: Option[A]
Converts to an option, discarding the error value.
-
abstract
def
toTry: Try[A]
Converts to a try.
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
isFailure: Boolean
True if attempt was not successful.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
productIterator: Iterator[Any]
- Definition Classes
- Product
-
def
productPrefix: String
- Definition Classes
- Product
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()