fix: handle IOException on OkHttp interceptor
Description
This MR handles IOException
inside OkHttp Interceptor's chain() method and returns a new HTTP response with custom code, message and body. The response is then propagated to the chain, maintaining the application's flow.
Tests
Tests are performed on an Android emulator to mimic a poor network connection. App Lounge is installed on a Google Play system image. The network type was set to EDGE and signal strength to poor.
Issues
https://gitlab.e.foundation/e/os/backlog/-/issues/2512?show=34810
10 commandments of code reviews
Summary by CodeRabbit
-
New Features
- Enhanced error handling for network requests, allowing the app to manage
IOException
gracefully. - Custom responses are now generated for network errors, improving user experience during connectivity issues.
- Introduced unit tests to validate the behavior of the interceptor, ensuring proper header management and response handling.
- Enhanced error handling for network requests, allowing the app to manage
-
Bug Fixes
- Improved stability by preventing application crashes due to unhandled network exceptions.
Edited by CodeRabbitAI