He probably forgot to add the implementation of handleFailure (I actually think he has it implemented in the BaseViewModel). Anyway, you could add a new state to the sealed class FriendsState:

sealed class FriendsState { 
object Loading : FriendsState()
object Empty : FriendsState()data class Success(val users: List<UserUiModel>) : FriendsState() data class Error(errorMessage: String) : FriendsState()

and pass something useful in the Error class, like an error message depending on the error (exception) that happened, or the exception itself (then you can handle the error in the best way in the fragment/activity) and imlpement the handleFailure function like this (doing it assuming it accepts general failures):

private fun handleFailure(failure: Failure.FeatureFailure) {
when(failure) {
is GetFriendsFailure -> state.value = FriendsState.Error

As you can see, we are notifying the controller through the LiveData posting the relative result, then you can react to that listening to the LiveData results indeed, like he is already doing for other results:

private fun onFriendsStateChange(state: FriendsState?) {           
when (val friendsState = state!!) {
is FriendsState.Loading -> showLoading()
is FriendsState.Empty -> showEmptyState()
is FriendsState.Success -> renderList(friendsState.users)
is FriendsState.Error -> // handle your error here

Senior Android Engineer @WeTransfer 🤖 🇻🇪🇮🇹 Paraglider, Runner, Kayaker.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store