Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - OkHttp Interceptor call onFailure

Anyone have any idea how I can call the onFailure callback from the Interceptor class attached to the OkHttp client?

like image 316
Mikerizzo Avatar asked May 26 '26 04:05

Mikerizzo


2 Answers

@warnyul comment was right. Once I threw the IOException, it triggered the failure.

like image 120
Mikerizzo Avatar answered May 28 '26 16:05

Mikerizzo


Try to throw an exception. When an interceptor throws an exception, okhttp calls the onFailure callback

like image 28
bvarga Avatar answered May 28 '26 16:05

bvarga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!