getOrCancel

inline fun <VALUE> Result<VALUE>.getOrCancel(doBeforeThrow: (Throwable) -> Unit = {}): VALUE

Returns the encapsulated value if this instance represents Success or throws CancellationException with Error.error as its cause if it is Error.

This method should be used in the case when you want to safely cancel your coroutine from inside.

If Error.error is not CancellationException then doBeforeThrow is called before throw.