catchingAs

inline fun <E : Throwable, T> catchingAs(a: (String?, Throwable) -> E, block: () -> T): KmmResult<T>(source)

Runs the specified function block, returning a KmmResult. Any non-fatal exception will be wrapped as the specified exception, unless it is already the specified type.

Usage: catchingAs(a = ::ThrowableType) { block }.


inline fun <E : Throwable, T, R> R.catchingAs(a: (String?, Throwable) -> E, block: R.() -> T): KmmResult<T>(source)
inline fun <E : Throwable, T> catchingAs(a: (Throwable) -> E, block: () -> T): KmmResult<T>(source)

See also


inline fun <E : Throwable, T, R> R.catchingAs(a: (Throwable) -> E, block: R.() -> T): KmmResult<T>(source)