Last active
November 28, 2017 08:29
-
-
Save gibson-khs/b051a3083a9f1cf501b5946d782d562a to your computer and use it in GitHub Desktop.
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
| if (throwable instanceof HttpException) { | |
| HttpException exception = (HttpException) throwable; | |
| RestError restError = (RestError) retrofit.responseBodyConverter( | |
| RestError.class, RestError.class.getAnnotations()).convert(exception.response().errorBody()); | |
| String errorMessage = restError.message; | |
| if (!TextUtils.isEmpty(errorMessage)) { | |
| Toast.makeText(context, errorMessage, Toast.LENGTH_SHORT).show(); | |
| } else { | |
| Toast.makeText(context, context.getResources().getString(R.string.default_error), Toast.LENGTH_LONG).show(); | |
| } | |
| } | |
| public class RestError { | |
| @SerializedName("error_message") | |
| public String message; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment