Created
August 6, 2018 08:24
-
-
Save chizoba/b93f4f54b9e5ca2da69973fb9e872bae to your computer and use it in GitHub Desktop.
Kobserver's onException() implementation
This file contains hidden or 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
| GitHubRequest(name).doRequest().observe(this, object : Kobserver<ResponseModel>() { | |
| override fun onException(exception: Exception) { | |
| // handle exception here | |
| when(exception){ | |
| is GitHubErrorHandler.ErrorConfig.NetworkException -> { | |
| Toast.makeText(this@MainActivity, exception.message, Toast.LENGTH_LONG).show() | |
| } | |
| is GitHubErrorHandler.ErrorConfig.GitHubException -> { | |
| Toast.makeText(this@MainActivity, exception.message, Toast.LENGTH_LONG).show() | |
| } | |
| else -> Toast.makeText(this@MainActivity, "Oops! Something went wrong.", Toast.LENGTH_LONG).show() | |
| } | |
| } | |
| override fun onSuccess(data: ResponseModel) { | |
| // update UI | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment