When using a `Result` it's often useful to map an ...
# language-proposals
a
When using a
Result
it's often useful to map an exception to another type of exception, has there any thought been given to adding something like
mapFailure
to the
Result
i.e.:
Copy code
inline fun <R> Result<R>.mapFailure(transform: (exception: Throwable) -> Throwable): Result<R> {
    return when {
        isFailure -> Result.failure(transform(exceptionOrNull()!!))
        else -> this
    }
}
Usage:
Copy code
Result
    .failure<String>(NullPointerException())
    .mapFailure {
        MyDomainException()
    }
m
I think this should be in the #stdlib channel