I faced the following error trying to extend RuntimeException and implement GraphQLError interface, defined in Java, from my Kotlin code. This is the error:
Accidental override: The following declarations have the same JVM signature (getMessage()Ljava.lang.string;):
public open fun <get-message>(): String? defined in NegativeCountException
public open fun getMessage(): String? defined in NegativeCountException
The following is my code:
class NegativeCountException() : RuntimeException(), GraphQLError {
override fun getMessage(): String? {
TODO("not implemented")
}
<...>
}
where GraphQLError
is an interface, defined in Java as shown bellow:
public interface GraphQLError {
String getMessage();
<...>
}
Seems like it clashes with getMessage()
defined in Throwable
.
I can't change code of the interface, because it comes from a library.
How can I create my own runtime exception, that will implement GraphQLError?
PS: I also tried the following, and received a very similar error:
class NegativeCountException(override val message: String?) : RuntimeException(), GraphQLError {
<...>
}
val message
hidden inside<...>
? That's what the error seems to say. – Vellavelleity