withError

inline fun <Error, OtherError, A> Raise<Error>.withError(transform: (OtherError) -> Error, block: Raise<OtherError>.() -> A): A

Execute the Raise context function resulting in A or any logical error of type OtherError, and transform any raised OtherError into Error, which is raised to the outer Raise.

fun test() {
either<Int, String> {
withError(String::length) {
raise("failed")
}
} shouldBe Either.Left(6)
}