Edhar Khimich
Edhar Khimich

Reputation: 1664

Get Composable function name inside it

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

Answers (1)

Edhar Khimich
Edhar Khimich

Reputation: 1664

I found the way:

object{}::class.java.enclosingMethod.name 

enclosingMethod is nullable so make sure to handle this case

Upvotes: 3

Related Questions