folding

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

Suspend variant of fold that propagates CancellationException for structured concurrency.

Executes block within this RaiseScope:

Return

The Out result of transform, recover, or catch.

Parameters

block

The suspend 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