chansek
02/02/2022, 8:00 AMexpect open class FirebaseException(message: String) : Exception
And in Android actual code:
import com.google.firebase.FirebaseException
actual typealias FirebaseException = FirebaseException
In the commonMain
code, I have a sub-class of this
class DocNotFoundException : FirebaseException(
"Fetched document is not present in the collection"
)
I have a Result
class for backend communication and here it looks like:
sealed class Result<out R> {
data class Success<out T>(val data: T) : Result<T>()
data class Error(val ex: Exception) : Result<Nothing>()
}
In my ViewModel
of Android module, when I use the above exception like this:
if (result is Result.Error && result.ex is DocNotFoundException) {
// Do something
}
I get an error saying:
Incompatible types: DocNotFoundException and kotlin.Exception /* = java.lang.Exception */
NOTE: This is only in IDE (AS), when I compile the code, it works fine.