icerockdev / moko-errors

Automated exceptions handler for mobile (android & ios) Kotlin Multiplatform development.
https://moko.icerock.dev/
Apache License 2.0
52 stars 6 forks source link

Add fast getting of mapped value #23

Closed Alex009 closed 2 years ago

Alex009 commented 3 years ago
inline fun <reified E : Throwable, reified T : Any> E.mapThrowable(): T {
    return ExceptionMappersStorage.throwableMapper<E, T>(T::class)(this)
}

usage:

val myException = IllegalArgumentException("fail!")
val message: StringDesc = myException.mapThrowable()