Last active
March 20, 2017 09:10
-
-
Save Fi5t/232650bd3b90706c4b90cd80d016c965 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
@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