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

fkrauthan

02/16/2022, 8:46 PM
Another quick
ktor-client
question. Is the
Copy code
scope.receivePipeline.intercept(HttpReceivePipeline.State) {
always getting executed even if the API call failed (e.g. Invalid Host or Timeout)? If yes what value would
context.response.status.value
contain? And if not what pipeline do I need to adjust to to catch that?
j

Javier

02/17/2022, 12:02 AM
There is no response and it should crash
f

fkrauthan

02/17/2022, 12:33 AM
Sorry so the intercept callback WILL be called but the
context.response.status.value
will fail?
or that would not be called at all? In that case is there any pipeline I can listen to to catch that type of error (I need to ALWAYS do some processing after a call is finished (regardless if it was successful or not))
a

Aleksei Tirman [JB]

02/17/2022, 2:26 PM
If there is a network failure then the
receivePipeline
won't be executed. To catch failures and normal responses you can intercept the
HttpRequestPipeline
using any phase before
Send
:
Copy code
client.requestPipeline.intercept(HttpRequestPipeline.Before) {}
f

fkrauthan

02/17/2022, 7:11 PM
but how do I catch an error with this?
6 Views