failWith

fun <R, E : Exception> ResultBlock<R, E>.failWith(block: () -> E): Nothing

Type safe way of throwing an exception.


infix inline fun <R, E : Exception> Result<R>.failWith(block: (Exception) -> E): R

Return the value of the success case or throws the exception from the "onFailure" block. This acts as a bridge to the standard kotlin.Result.


infix inline fun <R, E : Exception, R2, E2 : Exception> Result<R2, E2>.failWith(block: (E2) -> E): R2

Return the value of the success case or fail with the exception returned from the "block" block.