ground-android icon indicating copy to clipboard operation
ground-android copied to clipboard

[Code health] Add RX utility for handling errors and displaying them in the UI

Open scolsen opened this issue 4 years ago • 1 comments
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:

  1. Catch an error emitted by a stream.
  2. Log an exception
  3. (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.

scolsen avatar Mar 16 '21 14:03 scolsen

Similarly, we could add a helper called logErrors that reports them to logcat, but doesn't actually eat the error.

gino-m avatar Mar 17 '21 19:03 gino-m

We likely won't need this after we migrate to coroutines.

scolsen avatar Feb 27 '23 18:02 scolsen