wrapping

inline fun <E : Throwable, R> wrapping(asA: (String?, Throwable) -> E, block: () -> R): KmmResult<R>(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: wrapping(asA = ::ThrowableType) { block }.


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

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

Usage: wrapping(asA = ::ThrowableType) { block }.