getOrThrow

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

Returns the encapsulated value if this instance represents Success or throws the encapsulated exception if it is Error.

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