Hi everyone, I am trying to figure out how to use ...
# getting-started
c
Hi everyone, I am trying to figure out how to use Kotlin annotations and want to be able to annotate a function with a default error message that I can then use within the function. How do I access that error message?
Copy code
@Target(AnnotationTarget.FUNCTION)
annotation class DefaultErrorMessage(val defaultErrorMessage: String)

@DefaultErrorMessage("This is a test")
fun testErrorMessage() {
  // How do I access the DefaultErrorMessage?
}
Also, would it be possible to access that message from a function called by the annotated function for example:
Copy code
@Target(AnnotationTarget.FUNCTION)
annotation class DefaultErrorMessage(val defaultErrorMessage: String)

@DefaultErrorMessage("This is a test")
fun testErrorMessage() {
    testNestedAccess()
}

fun testNestedAccess() {
 // How do I access default error message?
}