and Then
Transforms the Success value of this Outcome, wrapping the result with outcome error-catching semantics.
Failure — returned unchanged.
If success throws, the exception is re-encapsulated or re-thrown via catch.
This is the outcome (non-suspend) alternative to mapSuccess — it catches exceptions rather than letting them propagate.
outcome { 4 }
.andThen { it * 2 } // Success(8)
.andThen { check(false) { "$it" } } // Failure(IllegalStateException("8"))
.andThen { 16 } // Remains Failure(IllegalStateException("8"))Parameters
The input Success value type.
The output Success value type after transformation.
The Failure error type.
Handles exceptions thrown by success. Defaults to rethrowing via rethrow.
The RaiseScope used to raise typed errors.
The transform applied to the Success value.
See also
Conditionally transforms the Success value, but only when predicate returns true. If predicate returns false, the Success is returned unchanged.
outcome { 4 }.andThen({ it > 0 }) { it * 2 } // Success(8)
outcome { 4 }.andThen({ it < 0 }) { it * 2 } // Success(4) — predicate false, unchangedParameters
The Success value type.
The Failure error type.
Guards the transformation. If false, success is skipped.
Handles exceptions thrown by success. Defaults to rethrowing via rethrow.
The RaiseScope used to raise typed errors.
The transform applied when predicate is true.