Reputation: 5830
This is the method I have:
private static class AvatarNotFound
extends Throwable
{
public AvatarNotFound(String message, @NonNull AddressableAvatarView addressableAvatarView)
{
super(message + getErrorMessageSuffix(addressableAvatarView));
}
private static String getErrorMessageSuffix(@NonNull AddressableAvatarView addressableAvatarView)
{
return ". Addressable: " + addressableAvatarView.toString();
}
}
converting to Kotlin it returns this code, which will become this:
private open class AvatarNotFound(message: String, addressableAvatarView: AddressableAvatarView) : Throwable(message + getErrorMessageSuffix(addressableAvatarView)) {
private fun getErrorMessageSuffix(addressableAvatarView: AddressableAvatarView): String {
return ". Addressable: $addressableAvatarView"
}
}
But it says that getErrorMessageSuffix
is an unresolved reference?
How can I make the constructor recognise it?
Upvotes: 0
Views: 55
Reputation: 591
try this may help you:
companion object{
private fun getErrorMessageSuffix(addressableAvatarView: AddressableAvatarView): String {
return ". Addressable: " + addressableAvatarView.toString()
}
}
}
Upvotes: 1
Reputation: 1
You can use companion object here, which will enable to access your method with class name.
companion object
{
private fun getErrorMessageSuffix(addressableAvatarView: AddressableAvatarView): String
{
return ". Addressable: $addressableAvatarView"
}
}
Upvotes: 0