https://kotlinlang.org logo
#ktor
Title
# ktor
d

divyanshunegi

07/06/2021, 10:21 AM
Hi All, I am working on a generic ktor client abstraction on my iOS and Android app where I want any client to call our networking library and make request and can send the Model they expect and Error Model they expect from the API.
Copy code
APIClient.GETRequest<UserData, Error>("/kmm-test", { success -> 
    Log.i(TAG, "Success: ${it.toString()}")
}, { error -> 
    Log.e(TAG, "Error: ${it.cause}")
}, { genericError ->
    Log.e(TAG, "Throwable: ${it.message}")
})
it looks something like this. I am handeling the generic error with ktor client engine. but the error from API is still a mystery to me, can someone guide me to a good direction ?
a

Aleksei Tirman [JB]

07/06/2021, 10:26 AM
There are different types of exception may be thrown. There is a feature request to address this problem by unifying exception types under one type.
👍 1
d

divyanshunegi

07/07/2021, 5:06 PM
Thanks @Aleksei Tirman [JB], I see the issue is open, will keep a tag on this issue, thanks again for sharing the link 🙏
3 Views