Reputation: 1664
How can I get a composable function name inside it ? I want to use a custom exception with the function name as a param.
class UnknownInfoCardTypeException(composableFunctionName: String) :
Exception("Unknown info card type was passed as a param to $composableFunctionName")
Upvotes: 3
Views: 1485
Reputation: 1664
I found the way:
object{}::class.java.enclosingMethod.name
enclosingMethod
is nullable so make sure to handle this case
Upvotes: 3