ground-android
ground-android copied to clipboard
[Code health] Add RX utility for handling errors and displaying them in the UI
trafficstars
@gino-m proposed adding an RX converter called handleErrors that would effectively serve the role of doOnError, onErrorReturn, and friends and do the following:
- Catch an error emitted by a stream.
- Log an exception
- (if applicable) show an error message in the UI in a consistent manner.
It'd be used (roughly) as follows:
offlineBaseMapRepository
offlineBaseMapRepository.getOfflineAreasOnceAndStream())
.getOfflineAreasOnceAndStream()
.compose(handleErrors("Error loading base map", ImmutableList.of()));
See Gino's original comment for more info.
Similarly, we could add a helper called logErrors that reports them to logcat, but doesn't actually eat the error.
We likely won't need this after we migrate to coroutines.