Skip to content

Instantly share code, notes, and snippets.

@Fi5t
Last active March 20, 2017 09:10
Show Gist options
  • Save Fi5t/232650bd3b90706c4b90cd80d016c965 to your computer and use it in GitHub Desktop.
Save Fi5t/232650bd3b90706c4b90cd80d016c965 to your computer and use it in GitHub Desktop.
...
@CallSuper
open fun onError(throwable: Throwable) {
when (throwable) {
is HttpException -> {
val responseBody = throwable.response().errorBody().string()
try {
val serverException = parseError(responseBody)
processServerException(serverError)
} catch (e: JsonSyntaxException) {
viewState.showError(R.string.unexpected_server_error)
}
}
is IOException -> viewState.showError(R.string.common_network_error)
else -> {
val errorMessage = throwable.message ?: getString(R.string.common_unexpected_error)
viewState.showError(errorMessage)
}
}
viewState.hideProgress()
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment