runSuspendCatching

inline suspend fun <T> runSuspendCatching(crossinline block: suspend () -> T): Result<T>(source)

Executes the provided block and wraps the outcome in a Result.

This helper keeps coroutine cancellation transparent by rethrowing CancellationException, while still converting any other exception into a failed Result. It avoids repeating the same try/catch logic across data sources.

Return

Result.success with the returned value or Result.failure with the thrown exception.

Parameters

block

The suspend function to execute.

Type Parameters

T

The type of the successful value.