Hello there!
I have a question regarding custom errors in KMP.
I have this code on kotlin side:
class BadRequest(override val message: String?) : Throwable()
@Throws(BadRequest::class, Throwable::class)
suspend fun login(email: String, password: String): Boolean {
...
throw BadRequest("some message")
}
On iOS side I use it like this:
do {
let loggedSuccessfully = try await api.login(email: email, password: password)
} catch {
print(error is BadRequest)
}
So on iOS it is always prints
false
. In debug I see that
error
is an
NSError
and cannot be casted to custom
BadRequest
. Is there any way to fix?