Depends on the use case
- If user is expecting data, then you need to send the errors all the way to your
UI
to notify user to make sure user won't just see a blank screen or experience unexpected UI. You can sealed classes in Kotlin for this case.
- If you are fetching something which user is not aware of, like syncing data from remote to Local cache in background, In cases like this user is not aware/ do not care about errors, your app should handle. Ideal way is to check in handle error in repository, if something fails, retrying it there or fetching data from alternate source etc.
- Third case would be handling at multiple levels, say you are fetching data from network, it failed, you can handle retry logic in repository level and after you exhaust your retry attempts but still it is failing then you need to acknowledge user as he might be expecting some thing to show up.
于 2021-02-18T07:21:56.390 回答