Hello again, I'm still having a slight issue with ...
# arrow
k
Hello again, I'm still having a slight issue with my accessTokens 😄
Copy code
fun <DTO> IO<DTO>.tryOnceWithAccessToken(accesToken: () -> IO<AccessToken>): IO<DTO> = withToken { accesToken().flatMap { withToken { raiseError(UnauthorizableException()) } } }


internal fun <DTO> IO<DTO>.withToken(restart: () -> IO<DTO>): IO<DTO> = handleErrorWith {

    if (it is HttpException && it.code() == 401) {

        restart()

    } else {

        raiseError(it)

    }

}
When I call that with an IO that first returns a 401, then should actually work (
MyNetworkIOThatWorksTheSecondTime.tryOnceWithAccessToken { refreshAccessToken() }
), I see that my second
withToken
never calls my network call a second time, and directly raises My
UnauthorizableException
. Any idea what I'm missing?