fold

inline fun <In, Out, Error> RaiseScope<Error>.fold(block: (scope: RaiseScope<Error>) -> In, catch: (Exception) -> Out = ::rethrow, recover: (error: Error) -> Out, transform: (value: In) -> Out): Out

Executes block within this RaiseScope and maps the result using transform, recover, or catch.

Warning: CancellationException is not propagated. Use folding in suspend contexts.

Return

The Out result of transform, recover, or catch.

Parameters

block

The block to execute within this scope.

catch

Maps thrown Exceptions to Out. Re-throws by default.

recover

Maps a raised Error to Out.

transform

Maps a successful In value to Out.

See also

Throws