How to throw an Exception of a dynamic type
Hi guys!
So I’m trying to write a method that catches a specified type of exception and throws a specified type of exception.
I have this:
inline fun mapException(
fromException: KClass,
toException: KClass,
block: () -> Returns
): Returns {
try{
Throwable::class
return block()
} catch(e: Exception) {
if (e is FromException) {
throw FromException(e.message, e)
} else {
throw e
}
}
}
But I’m getting the...