Skip to content

Instantly share code, notes, and snippets.

@ragdroid
Last active March 10, 2017 18:21
Show Gist options
  • Save ragdroid/4227d9e1cab24d0a187f669ed8bdaeee to your computer and use it in GitHub Desktop.
Save ragdroid/4227d9e1cab24d0a187f669ed8bdaeee to your computer and use it in GitHub Desktop.
How to be a MockStar - Issue Errors
if (throwable instanceof HttpException) {
if (((HttpException) throwable).code() ==
HttpURLConnection.HTTP_NOT_FOUND) {
if (getView() != null) {
getView().showErrorDialog("Lost!");
}
} else if (((HttpException) throwable).code() ==
HttpURLConnection.HTTP_UNAVAILABLE) {
if (getView() != null) {
getView().showErrorDialog("Fire on the Server");
}
} else if (((HttpException) throwable).code() ==
HttpURLConnection.HTTP_UNAUTHORIZED) {
if (getView() != null) {
getView().showErrorDialog("You shall not pass!");
}
}
} else {
if (getView() != null) {
getView().showErrorDialog(throwable.getMessage());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment