Kashismails
09/04/2023, 10:28 AMThomas Urbanitsch
09/04/2023, 10:49 AMfun createObjectByPackageName(packageName: String, className: String): Any? {
return try {
Class
.forName("$packageName.$className")
.getDeclaredConstructor().newInstance()
} catch (e: Exception) {
when(e) {
is ClassNotFoundException,
is IllegalAccessException,
is InstantiationException -> e.printStackTrace()
else -> throw e
}
null
}
}
or write your own multicatch extension 🤷
(disclaimer: i didn’t try this 😅 )
(also not sure how this is related to multiplatform?)Kashismails
09/04/2023, 10:51 AMiXPert12
09/04/2023, 11:36 AMKashismails
09/04/2023, 11:37 AM