outcome
An alias for outcomeOf that uses a String as the Error type.
Useful for simple cases, where you fail to provide a specific error type, and just want to use any message string or Throwable.message.
Return
An Outcome instance containing the result of the block execution.
Parameters
The block that provides the value for the success outcome.
See also
An alias for outcomeOf that uses a String as the Error type.
Useful for simple cases, where you fail to provide a specific error type, and just want to use any message string or Throwable.message.
Receiver
Return
An Outcome instance containing the result of the block execution.
Parameters
The block that provides the value for the success outcome.
See also
Wraps a value of type Ok as an Outcome based on a predicate.
If the predicate returns true
, the value is wrapped as a Success. If the predicate returns false
, the faulter function is invoked to produce an Error which is then wrapped as a Failure.
Return
An Outcome containing the value as a Success or an Error as a Failure.
Parameters
The type of the value to wrap.
The type of the error produced by the faulter.
A function that determines if the value is successful.
A function that produces an error if the predicate is false
.
Return
Parameters
The type of the value to wrap.