intercept

abstract suspend fun <T> intercept(endpoint: NetworkEndpoint, attempt: Int, proceed: suspend () -> T): T

Called once per attempt, wrapping the work that executes it. Implementations must call the supplied proceed function to actually perform the attempt (typically exactly once) and return its result; failing to call it — or swallowing an exception it throws — will silently break the request.

Parameters

endpoint

the endpoint being called.

attempt

the 0-based attempt index (0 = first try), matching NetworkEvent.attempt.

proceed

performs the attempt. Propagates the attempt's exception (mapped to NetworkError or otherwise) if it fails.