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

wakingrufus

04/26/2019, 4:41 PM
hello, I have a question about client error handling. if i call
request<HttpResponse>
I can check for status and other things in order to do my own error handling, but then i can't leverage the built in Json deserialization of my object. but if i call
request<MyObject>
in order to get the deserialization, it is not clear how to check and handle errors. I am looking for something like Fuel's `Result.fold`:
Copy code
inline fun <X> fold(success: (V) -> X, failure: (E) -> X): X = when (this) {
        is Success -> success(this.value)
        is Failure -> failure(this.error)
    }
. is there something like this in ktor?
o

obobo

04/26/2019, 5:39 PM
If you use
HttpResponse
you can use
receive()
to automatically deserialize json.
w

wakingrufus

04/26/2019, 5:48 PM
Oh I didnt see that. Ill try that, thanks!
That worked for me. Thanks!