Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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")
like image 776
Edgar Khimich Avatar asked Oct 21 '25 17:10

Edgar Khimich


1 Answers

I found the way:

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

enclosingMethod is nullable so make sure to handle this case

like image 196
Edgar Khimich Avatar answered Oct 23 '25 06:10

Edgar Khimich